473,573 Members | 2,820 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error downloading excel file

Greetings,

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

System.Web.Http Context.Current .Response.Conte ntType =
"applicatio n/vnd.ms-excel";

System.Web.Http Context.Current .Response.AddHe ader("Content-Disposition",
"attachment ; filename=\"x.xl s\"");

System.Web.Http Context.Current .Response.Write ( "abc" );
System.Web.Http Context.Current .Response.Flush ();
System.Web.Http Context.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

*** Sent via Developersdex http://www.developersdex.com ***
Jan 11 '06 #1
4 3073
Try Response.End() instead of Response.Close( )

--
Andrew Robinson
http://blog.binaryocean.com
"Kevin R." <ka****@riveron e.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Greetings,

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

System.Web.Http Context.Current .Response.Conte ntType =
"applicatio n/vnd.ms-excel";

System.Web.Http Context.Current .Response.AddHe ader("Content-Disposition",
"attachment ; filename=\"x.xl s\"");

System.Web.Http Context.Current .Response.Write ( "abc" );
System.Web.Http Context.Current .Response.Flush ();
System.Web.Http Context.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

*** Sent via Developersdex http://www.developersdex.com ***

Jan 11 '06 #2
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
*** Sent via Developersdex http://www.developersdex.com ***
Jan 16 '06 #3
Try Response.Clear( ) before you start adding things to the Response.

http://www.csvreader.com/csv_samples.html
The section marked "Download DataTable to Web Browser as CSV File".

Jan 17 '06 #4

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\userna me\LocalSetting s\Temporary Internet
Files\Content.I E5\KV5ZIYV1\myf ilename.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

*** Sent via Developersdex http://www.developersdex.com ***
Jan 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3849
by: Jocelyn Duhaylungsod | last post by:
I have been getting the following server errors sporadically while downloading excel, csv or xml file. Internet Explorer cannot download <file name> from <IP address> "The server returned an invalid or unrecognized response" / "The connection with the server was reset" I'm using Response.BinaryWrite to send down the file content as...
0
1667
by: ed | last post by:
Hello All. I have seen many posts slightly similar to this question with no answer. Maybe you have some FAQs or something, sorry if I looks repetitive. Here is my Problem: In my application I have a link button inside a module on an IBuySpy Portal to download an excel file. I generate the excel file using the Office 2003
2
1686
by: Radha Raman | last post by:
hi I am facing problem in downloading excel sheet with macros. So i decide to create a EXE for that. But how to create that EXE for downloading excel file, i don't know. Plz help me
1
1671
by: Muddasir | last post by:
Hello everyone. I am facing problem in downloading .xls file. I generate report and save data in excel sheet on server. and once user click the 'save data in excel format', an excel sheet is been created on the server.once created then user can download that file. i am able to download file but the problem is that when user apply sorting...
0
7760
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7996
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8191
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7760
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5284
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3724
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2185
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1289
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.