I have some code on an aspx page then when users loads the page it starts downloading a zip. Looks like this:
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileSaveName);
Response.TransmitFile(zipPath);
Response.End();
The problem is the FIRST time this is hit I get the following error:
The zip file exists and is not in my wwwroot. If I refresh the page the file will download fine.
If I wrap the code in a Try Catch I get a System.Threading.Threadabort exception with the message:
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.
N开发者_高级运维OTE: I actually get that exception every time. I guess its just to do with the Response.End
Thanks for any help!
Response.End would probably throw an exception to get out quick'n'dirty so that's fine, however, that file.. I suspect your Response.End is messing things up, have you tried to do a .Flush() first? You might get a clue by using Fiddler to examine what the server actually returns
精彩评论