IE unable to open Excel stream

  • Thread starter Christian W. Larsen
  • Start date

C

Christian W. Larsen

I want to export a datagrid to Excel. Here is the code:

[after datagrid databind]

Response.Clear();

Response.Buffer = true;
Response.AddHeader("content-disposition",
"attachment;filename=FileName.xls");
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new
HtmlTextWriter(stringWrite);
DataGrid1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();

When I open the page with Internet Explorer I get this:

Internet Explorer cannot download [file name] from [server name]
Internet Explorer was not able to open this Internet site. The requested
site is either unavailable or cannot be found. Please try again later.

The funny thing: it works with Firefox - no problems at all.
Mime types on IIS are ok.
 
Ad

Advertisements

A

Alvin Bruney [ASP.NET MVP]

Uncheck the show friendly error messages to see what the real error is. It
should give you a good enough clue.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top