简体   繁体   中英

Unable to export to Excel in IE 8

i am unable to export to excel in IE 8. i keep getting the following: "IE cannot download filename.aspx from url." "IE was not able to open this internet site. t he requested site is either unavailable or cannot be found. pelse try again"

looks to me like it's itgnoring the https, and trying to open http, but i could be wrong. per this article: http://support.microsoft.com/kb/323308

my code is:

 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();

I found a lead that suggests you need to disable cache control headers.

Give this a shot:

 Response.Cache.SetCacheability(HttpCacheability.NoCache);

Source: Random Forum Conversation | Another Possible Lead

Also: SetCacheability

...I was hoping to uncover some deeper understanding, but that's all I found.

Try getting rid of the space in your content disposition, also try adding quotes around the filename:

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

Is there a reason you are using a string writer with write instead of a stream with binarywrite?

the problem was with the IIS application pool. resolved.

I just was able to fix this issue. I added the following lines after response.clear() ...

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM