Streaming Excel Content

G

Guest

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
 
M

Martin Dechev

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 said:
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:
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.
 
G

Guest

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
 
G

Guest

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,808
Messages
2,569,686
Members
45,452
Latest member
AmberLayde

Latest Threads

Top