Joh*_*ohn 6 c# asp.net cross-browser download

当我尝试从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();
}
Run Code Online (Sandbox Code Playgroud)
当我在chrome中使用开发人员工具时,它将Resource解释为Other,但是使用MIME类型undefined进行传输.错误,但下载了文件,但IE正在抛出图像中显示的错误,我该怎么办,谢谢.
当我使用Visual Studio运行网站时,我能够在IE8中下载该文件,但是当我尝试从上传到服务器的网站下载时,我收到上述错误,错误仅在IE 8中.
我尝试打开和关闭IE浏览器兼容模式,即使这样我也收到同样的错误.
这是我的头脑内容
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
Run Code Online (Sandbox Code Playgroud)
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Run Code Online (Sandbox Code Playgroud)
通过从代码中删除这一行来解决。
| 归档时间: |
|
| 查看次数: |
2861 次 |
| 最近记录: |