Double 'open' downloading a file in an ASP.NET page

K

Keith

I have a minor problem with a piece of code I have written to download
a CSV file in an ASP.NET application. It works fine except that if the
user presses the Open button on the IE6 download dialogue, then the
dialogue is presented a second time. Pressing the Open button again
works fine. Pressing the save button also works fine.

The code (c#) looks like:

if (Page.IsPostBack) {
Response.Clear();
Response.BufferOutput=true;
Response.ContentType="application/csv";
Response.AppendHeader("content-disposition","attachment;
filename=servicelist.csv");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetExpires(DateTime.Now);
Response.Write(sb.ToString());
Response.End();
return;
}

Any assistance would be appreciated.

Keith
 
C

Carl Prothman [MVP]

Keith said:
I have a minor problem with a piece of code I have written to download
a CSV file in an ASP.NET application. It works fine except that if the
user presses the Open button on the IE6 download dialogue, then the
dialogue is presented a second time. Pressing the Open button again
works fine. Pressing the save button also works fine.
Response.ContentType="application/csv";
Response.AppendHeader("content-disposition","attachment;
filename=servicelist.csv");

Keith,
Try using "inline" rather than "attachment".

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP

Hire top-notch developers at
http://www.able-consulting.com
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top