我编写了以下c#代码,用于在应用程序中下载附件,当我运行该代码时,可以使用Internet Explorer Mozilla下载文件,但这在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();
谁能帮我在Chrome中进行下载时需要做些什么更改
如果"application/octet-stream"
您收到表单的回复,则Google Chrome浏览器将不会为您打开“文件保存”窗口。
如果知道的话,内容类型应该是任何已知的类型。例如"application/pdf"
,"image/png"
或其他。请参阅MIME类型的完整列表
看到这个问题是什么可以阻止Chrome下载文件?想要查询更多的信息。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句