This is a problem I've had in the past, but I forgot if I ever solved it or not. I have it so when the user clicks on an asp:linkbutton it triggers a download for a file. File downloads successfully without a problem. However, after it downloads if the user clicks to download again or clicks a button a postback happens and the page refreshes, clearing out everything such as tables or text. How do I prevent this from happening?
Here's the code executing for the download.
string name = Path.GetFileName(filePath);
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=\"" + name + "\"");
Response.ContentType = mimeType;
Response.BinaryWrite(file);
Response.End();
NOTES:
- The linkbutton control is NOT created behind the scenes in code, if that makes a difference.
- The file does not download when clicking the link on the second time. Only a refresh happens.
- This is part of a DNN module