SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created an application page to download file. I'm using the following code to download the file. After downloading file if I press the download button again it doesn't respond or post back. I assume calling Response.End() ends the connection between server and client. Is there any work around to this issue.

Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=output.pdf");
share|improve this question

I've done this by using the code below (some lines not included), which is in the Page_Load method of the Application page.

The App page is loaded from a content page via a click on an asp:HyperLink control, which has CSS applied to make it look like a button.

Response.AppendHeader("Content-Disposition:", "attachment; filename=" + filename);
Response.ContentType = "application/download";


SPFile file = web.GetFile(fullUrl);


share|improve this answer
Hi Howard, Thanks for your reply. Actually i'm loading the application page via a click of a ribbon item that I created and then on the application page I'm generating a file programmatically and then calling the code above. I don't know how to load the application via a content page.. could you point to some samples – Kannan Jan 20 '12 at 1:29
Well the content page simply hosts a user control, which is defined in the page's layout. This control renders the link. You can do the same thing with a custom web part, or even a standard content editor web part. The following link may help: – Howard Jan 20 '12 at 8:43

The following link was very helpful in understanding the response issue that I was facing. It was solved by setting a few flags.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.