By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,719 Members | 1,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,719 IT Pros & Developers. It's quick & easy.

Streaming Excel Content

P: n/a
I am trying to stream html content as excel data from a
webserver to an IE browser with the following ASP.NET code

First Scenario:
-----------------
An aspx page with a server side button control.
When button is clicked, form is posted and the following code is executed on the server side.

response.Buffer =true;
response.Charset = "";
response.ContentType = "application/vnd.ms-excel";
response.AppendHeader("Content-Disposition", "attachment;filename=sample.xls");
response.Write(data);

IE shows two Open/Save Dialog boxes. It is pretty weird for
the dialog to be prompted two times to download a single
file. I am not sure whether this is problem in IE or I
have to do any anything on the HTTP headers side..
I am using IE 6.0 with SP1.

Second Scenario:
--------------------
Another aspx page which has the same above listed code in the Page_Load event. When this page is requested , IE throws up only one
dialog box to download the file.

I am not sure why IE behaves differently under the above stated scenarios. I like IE to prompt only once. Any help to solve this problem will be appreciated.

Thanks
Krishna

Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi, Krishna,

In the first case it looks like the code in the method that handles the
click event of the button is executed twice.

The most probable reson for this is that this handler is attached to the
event twice - once in the auto-generated code by the VS, and once again
automatically because the attribute AutoEventWireUp is set to true (this is
the default value) in the Page directive. Try adding AutoEventWireUp="False"
in the Page directive.

Hope this helps
Martin
"Krishna" <an*******@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
I am trying to stream html content as excel data from a
webserver to an IE browser with the following ASP.NET code

First Scenario:
-----------------
An aspx page with a server side button control.
When button is clicked, form is posted and the following code is executed on the server side.
response.Buffer =true;
response.Charset = "";
response.ContentType = "application/vnd.ms-excel";
response.AppendHeader("Content-Disposition", "attachment;filename=sample.xls"); response.Write(data);

IE shows two Open/Save Dialog boxes. It is pretty weird for
the dialog to be prompted two times to download a single
file. I am not sure whether this is problem in IE or I
have to do any anything on the HTTP headers side..
I am using IE 6.0 with SP1.

Second Scenario:
--------------------
Another aspx page which has the same above listed code in the Page_Load event. When this page is requested , IE throws up only one dialog box to download the file.

I am not sure why IE behaves differently under the above stated scenarios. I like IE to prompt only once. Any help to solve this problem will be
appreciated.
Thanks
Krishna

Nov 18 '05 #2

P: n/a
Hi Martin
Thanks for looking into the problem
AutoEventWireUp="False" is already set in my page. So, I think the code is getting executed only once. I am not sure whether this is anything to do with ASP.NET sending different HTTP headers for the two cases

Thank
Krishn

Nov 18 '05 #3

P: n/a
I just ran into the same problem today.
Did not try to debug it yet though.
I have 2 different methods to download Excel data and it only did this on
the new one.
The other was fine. Same thing for text files or XML files or .mdb files.
Just the new method got the double prompt.
I thought it was just my PC. Maybe it needed a re-boot.

Any progress??
--
Joe Fallon

"Krishna" <an*******@discussions.microsoft.com> wrote in message
news:D3**********************************@microsof t.com...
Hi Martin,
Thanks for looking into the problem.
AutoEventWireUp="False" is already set in my page. So, I think the code is getting executed only once. I am not sure whether this is anything
to do with ASP.NET sending different HTTP headers for the two cases.
Thanks
Krishna

Nov 18 '05 #4

P: n/a
Hi Joe
I havent done any progress in this issue other than finding out that this happens only when form method is "POST". I am yet to find out what is the difference in HTTP headers,if any, seen by IE browser for it to prompt twice
What is the significance difference between your old method and new method?..

Thank
Krishna
Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.