download a file from a web page: first time works, next times not

F

Fabio Mastria

Hi all

on a page aspx of my web application (vs2005, .net 2.0), I have an
imagebutton

Its click event looks like this:

filename = createFile(); //create a file on server filesystem

if (File.Exists(filename))
{
Response.Clear();
Response.ContentType = "application/x-download";
Response.AddHeader("Content-disposition", "attachment;filename=" +
Path.GetFileName(filename));
Response.WriteFile(filename);
Response.End();
}

First time user click on the image and download the file -> all done, all
ok...

If user retry to click on the image an exception is raised on the row
"Response.End()". The exception is not readable. The message (not the
Message field, but visual studio message) is "Impossible evaluate the
expression because the code is optimized or a native frame is at the start
of the calls stack"

Can Someone tell me how solve this problem?

Thank you all
Fabio
 

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,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top