资源解释为“其他”,但传输时未定义 MIME 类型。 IE 错误(Asp.net 网站)
当我尝试从 Chrome 下载时,它工作正常,但在 IE 8 中,它没有下载,而是显示上面的错误,
protected void btn_ExcelDownload_Click(object sender, EventArgs e)
{
Grid_UserTable.Columns[0].Visible = false;
string subject = lbl_Subj.Text;
Response.Buffer = true;
Response.Clear();
Response.ClearHeaders();
Response.AddHeader("Cache-Control", "no-store, no-cache");
Response.AddHeader("content-disposition", "attachment;filename=" + subject + "-Status.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
Grid_UserTable.RenderControl(htmlWrite);
rptList.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
当我在 Chrome 中使用开发人员工具时,它会将资源解释为“其他”,但以未定义的 MIME 类型进行传输。错误但下载了文件,但 IE 抛出图像中显示的错误,我该怎么办,谢谢。
当我使用 Visual Studio 运行网站时,我可以在 IE8 中下载该文件,但是当我尝试从服务器上传的网站下载该文件时,我收到上述错误,该错误仅在 IE 8 中出现
。尝试打开和关闭 IE 浏览器兼容模式,即使这样我也收到同样的错误。
这是我的头条内容
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
WHen I try to download from Chrome it works fine, but in IE 8 it is not downloading it is showing the error above,
protected void btn_ExcelDownload_Click(object sender, EventArgs e)
{
Grid_UserTable.Columns[0].Visible = false;
string subject = lbl_Subj.Text;
Response.Buffer = true;
Response.Clear();
Response.ClearHeaders();
Response.AddHeader("Cache-Control", "no-store, no-cache");
Response.AddHeader("content-disposition", "attachment;filename=" + subject + "-Status.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
Grid_UserTable.RenderControl(htmlWrite);
rptList.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
When I used developer tool in chrome it gave Resource interpreted as Other but transferred with MIME type undefined. error but downloaded the file, but IE is throwing the error shown in the image, what should i do, thanks.
I am able to download the file in IE8 when I run the website using Visual studio, but when I try to download it from the website which is uploaded in server I am getting the above error,, The error is only in IE 8.
I tried changing the IE browser Compatibility mode on and off, even then I receive same error.
This is my head content
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过从代码中删除这一行来解决。
Solved by removing this line from the code.
这可能有效:
来源链接
This might work:
Source link