从Google Chrome下载文件时出现网络错误
我编写了下面的c#代码来下载我的应用程序中的附件,当我运行代码时,我可以使用Mozilla,Internet Explorer下载文件,但这不适用于谷歌浏览器。
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下载文件? 欲获得更多信息。