THY02K
October 25th, 2005, 11:18 PM
Hi, I'm writing this small code segment which handles file download:
Response.Clear()
Response.ContentType = mime_type Response.OutputStream.Write(item, 0, item.Length)
Response.End()
However, ThreadAbortException is raised everytime Response.End is called:
System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.End()
at
However, this seems to be okay on my development box: ie. Client was able to download the file nonetheless. However, when this same app is deployed to Production machine, ASP.NET on production machine seems to be handling ThreadAbortException differently - the exception was still raised, I caught it with a try-catch block, users are still able to download the file (PDF btw), but download time is like 10 minutes!? (While same app on development download is like 5 sec - same PDF file) - it seems like production and development box is handling ThreadAbortException differently.
I tried to get around this by Response.Flush instead of Response.End but then a different (client side) exception arise saying the file is corrupted ("File is damaged and could not be repaired")??!
Just before I go... Response.Redirect("...", False) won't do - I'm trying to do a download here. (ie. I write to response stream ... a Save File dialog pops on client side)
Response.Clear()
Response.ContentType = mime_type Response.OutputStream.Write(item, 0, item.Length)
Response.End()
However, ThreadAbortException is raised everytime Response.End is called:
System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.End()
at
However, this seems to be okay on my development box: ie. Client was able to download the file nonetheless. However, when this same app is deployed to Production machine, ASP.NET on production machine seems to be handling ThreadAbortException differently - the exception was still raised, I caught it with a try-catch block, users are still able to download the file (PDF btw), but download time is like 10 minutes!? (While same app on development download is like 5 sec - same PDF file) - it seems like production and development box is handling ThreadAbortException differently.
I tried to get around this by Response.Flush instead of Response.End but then a different (client side) exception arise saying the file is corrupted ("File is damaged and could not be repaired")??!
Just before I go... Response.Redirect("...", False) won't do - I'm trying to do a download here. (ie. I write to response stream ... a Save File dialog pops on client side)