Tuesday, December 2, 2008

Response.End vs Response.Close

I was having an issue that took me a lot longer to pin down than it should have. I have an application that saves all of it's 'attachments' to a database on a server. If a user wants to see these attachments, they get sent to a 'viewattachment' web page, which, depending on the file, either allows the user to save it to their local machine, or displays it in the browser (like for an image).

For some reason, the larger files (the images) were basically freezing during the page load. When I would hit the stop button on the browser, part of the image would show, but leaving it to run would never really work. I finally found the issue, which was in 1 line:

Response.End();
Response.Flush();
Response.Close();

I don't know why I had the 'End' at that particular point, but putting it there meant that it would end the response before it had finished painting it on the browser. It basically just killed the page. Moving the 'End' so that it came after 'Close' fixed the issue.

Now I just need to find out if it's even necesary to call response.End if I'm already calling response.Close.

Labels: , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home