资源解释为“其他”,但传输时未定义 MIME 类型。 IE 错误(Asp.net 网站)

发布于 2024-12-15 16:17:40 字数 1425 浏览 0 评论 0原文

在此处输入图像描述

当我尝试从 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" />

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

装迷糊 2024-12-22 16:17:40
  Response.Cache.SetCacheability(HttpCacheability.NoCache);

通过从代码中删除这一行来解决。

  Response.Cache.SetCacheability(HttpCacheability.NoCache);

Solved by removing this line from the code.

无远思近则忧 2024-12-22 16:17:40

这可能有效:

Response.ClearHeaders();
Response.AddHeader("Cache-Control", "no-store, no-cache");

来源链接

This might work:

Response.ClearHeaders();
Response.AddHeader("Cache-Control", "no-store, no-cache");

Source link

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文