views:

42

answers:

1

Hey guys,

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:

alt text

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.

NOTE: I actually get that exception every time. I guess its just to do with the Response.End

Thanks for any help!

A: 

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

Onkelborg
well its super weird, think its an IE issue. works fine in firefox. if I click a link in IE the first time for the download it works, its just if i copy paste it.
nextgenneo
Have you tried http://www.fiddler2.com/fiddler2/ yet? If not, do that. It's good to know where things go wrong. I see one thing in your code that doesn't look good, I think there should be " (quotes) around the filename in content-disposition
Onkelborg