gpt4 book ai didi

c# - 如何在mvc中导出文本文件?

转载 作者:太空宇宙 更新时间:2023-11-03 13:43:59 24 4
gpt4 key购买 nike

我使用流编写器在我的代码中生成文本文件,流编写器使用 Web 应用程序的 mvc 格式。但是我的文本文件没有下载我的页面?我的示例代码如下:

//文件具有流写入器格式的所有值

return File(file, "text/plain", "Export.txt");

最佳答案

尝试在返回之前添加:

var cd = new System.Net.Mime.ContentDisposition
{
FileName = "Export.txt",
Inline = false,
};
Response.AppendHeader("Content-Disposition", cd.ToString());

return File(file, "text/plain");

关于c# - 如何在mvc中导出文本文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15972013/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com