Error downloading excel file

  • Thread starter Thread starter Kevin R.
  • Start date Start date
K

Kevin R.

Greetings,

I have the following code that attempts to download an excel file:

System.Web.HttpContext.Current.Response.ContentType =
"application/vnd.ms-excel";

System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition",
"attachment; filename=\"x.xls\"");

System.Web.HttpContext.Current.Response.Write( "abc" );
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.Close();

But I get the following error when I executed the last statement:

"Internet Explorer was not able to open this internet site..."

I have disabled "Content Expiration" in IIS HTTP Headers and ensured
"no-cache" is not added to the Response Header.

Has anyone seen this and knows what is causing it?

Help is much appreciated,
kr
 
I got the same error. I tried to download a .csv file and hit the same
problem, so this is not Excel related. It must be either something in my
IE 6.0 or a .NET configuration issue.

Any other ideas?

thx,
kr
 
Shriop,

Thanks for your suggestion and the reference URL. It took me one step
closer to the solution. Now, when I click the "Save" button of the "File
Download" dialog it saves the content as a .xls file with no problem.

But, if I choose to open the content by clicking on the "Open" button
and if Excel app is not already open in my desktop, it opens Excel
application with the following error:

'C:\Document and Settings\username\LocalSettings\Temporary Internet
Files\Content.IE5\KV5ZIYV1\myfilename.xls could not be found...'

If however, Excel is already open prior to clicking the "Open" button it
shows the content in Excel with no problem. Is this normal behavior? How
can I make it to launch Excel first and show the content?

your help is much appreciated.

Regards,
kr
 
Back
Top