Madam Zu Zu
Madam Zu Zu

Reputation: 6615

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

Upvotes: 0

Views: 2623

Answers (4)

Chris Brickhouse
Chris Brickhouse

Reputation: 648

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 ")

Upvotes: 0

Madam Zu Zu
Madam Zu Zu

Reputation: 6615

the problem was with the IIS application pool. resolved.

Upvotes: 0

John Koerner
John Koerner

Reputation: 38087

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?

Upvotes: 0

Brian MacKay
Brian MacKay

Reputation: 32037

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.

Upvotes: 2

Related Questions