Reputation: 914
I have an ASP.NET webpage that generates a file and returns it after the user submits a form;
However the file contents are being modified when sent by ASP.NET.
The code is below:
Response.TransmitFile(fileName)
Response.[End]()
This causes the file contents to contain this text at the end of it -
Thread was being aborted.
This corrupts the file, as it's contents are encrypted and are read by an application later on.
Is there a way for me to send a file after a user clicks a button in ASP.NET without it causing this file corruption?
It's not something I can store permanently and link to, it's generated based on user input on the site.
Upvotes: 0
Views: 103
Reputation: 1555
Ending the response generates an error. Wrap the response.end in an error handler like so:
try
response.end
catch ex as System.Threading.ThreadAbortException
' do nothing
end try
Upvotes: 1