ASP.NET Response.TransmitFile Error on first boot

I have code on an aspx page, then when users load the page , it starts zip loading. Looks like that:

            Response.ContentType = "application/octet-stream";
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileSaveName);
            Response.TransmitFile(zipPath);
            Response.End();

The problem is that the first time this happens. I get the following error:

alt text

The mail file exists and is not in my wwwroot. If I refresh the page, the file will load normally.

If I complete the code in 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.

NOTE. I get this exception every time. I assume this is easy to do with Response.End

Thanks for any help!

+3
source share
1 answer

Response.End, , , quick'n'dirty, , , .. , Response.End , .Flush() ? , Fiddler, ,

0

Source: https://habr.com/ru/post/1770216/


All Articles