0

我无法在 IE 8 中导出到 excel。我不断收到以下信息:“IE 无法从 url 下载 filename.aspx。” “IE 无法打开此 Internet 站点。请求的站点不可用或找不到。请再试一次”

在我看来,它忽略了 https,并试图打开 http,但我可能是错的。根据这篇文章:http: //support.microsoft.com/kb/323308

我的代码是:

 StringWriter sw = new StringWriter();
                HtmlTextWriter htw = new HtmlTextWriter(sw);
                gvResources.RenderControl(htw);

                Response.ClearContent();
Response.ClearHeaders()
                Response.AddHeader("Content-Disposition", "attachment; filename=AdHocReport.xls");
                Response.ContentType = "application/vnd.ms-excel";
                Response.Write(sw.ToString());
                Response.End();
4

4 回答 4

2

我发现一条线索建议您需要禁用缓存控制标头。

试一试:

 Response.Cache.SetCacheability(HttpCacheability.NoCache);

来源:随机论坛对话| 另一个可能的线索

另外:SetCacheability

...我希望能发现一些更深层次的理解,但这就是我发现的全部。

于 2012-07-06T13:03:14.340 回答
0

尝试摆脱内容配置中的空间,也尝试在文件名周围添加引号:

 Response.AddHeader("Content-Disposition", "attachment;filename=\"AdHocReport.xls\"");

您是否有理由使用带有写入功能的字符串写入器而不是带有二进制写入的流?

于 2012-07-06T13:34:38.860 回答
0

问题出在 IIS 应用程序池上。解决。

于 2012-08-06T13:22:32.373 回答
0

我只是能够解决这个问题。response.clear()我在...之后添加了以下几行

    Response.ClearHeaders()
    Response.AddHeader("Cache-Control", "no-store, no-cache ")
于 2013-08-14T18:26:30.957 回答