Tri*_*uri 2 c# asp.net asp.net-mvc c#-3.0 c#-4.0
我编写了下面的 C# 代码用于下载应用程序中的附件,当我运行代码时,我可以使用 Mozilla、Internet Explorer 下载文件,但这在 Google Chrome 中不起作用。
string base64FileString = result;
byte[] binaryFile = Convert.FromBase64String(base64FileString);
Response.ContentType = "application/octet-stream";
Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", Request.QueryString["FILENAME"]));
Response.Clear();
Response.BufferOutput = false;
Response.ClearContent();
Response.BinaryWrite(binaryFile);
Response.Flush();
Response.Close();
Run Code Online (Sandbox Code Playgroud)
谁能帮助我在 Chrome 中下载需要做哪些更改
"application/octet-stream"如果您通过表单回复,Google Chrome 浏览器不会为您打开“文件保存”窗口。
内容类型应该是已知的任何内容(如果您知道的话)。例如"application/pdf","image/png"或者其他什么。请参阅MIME 类型的完整列表
请参阅此问题什么会阻止 Chrome 下载文件?了解更多信息。
| 归档时间: |
|
| 查看次数: |
14818 次 |
| 最近记录: |