我在上课
http://pastebin.com/aK0zcxMN
(版本
http://dotnetslackers.com/articles/aspnet/Range-Specific-Requests-in-ASP-NET.aspx
)以保护下载从水蛭和提供简历。它很好用,但偶尔我会
System.Threading.ThreadAbortException: Thread was being aborted.
at System.Web.UnsafeNativeMethods.EcbFlushCore(IntPtr pECB, Byte[] status, Byte[] header, Int32 keepConnected, Int32 totalBodySize, Int32 numBodyFragments, IntPtr[] bodyFragments, Int32[] bodyFragmentLengths, Int32 doneWithSession, Int32 finalStatus, Int32 kernelCache, Int32 async, ISAPIAsyncCompletionCallback asyncCompletionCallback)
at System.Web.Hosting.ISAPIWorkerRequestInProcForIIS6.FlushCore(Byte[] status, Byte[] header, Int32 keepConnected, Int32 totalBodySize, Int32 numBodyFragments, IntPtr[] bodyFragments, Int32[] bodyFragmentLengths, Int32 doneWithSession, Int32 finalStatus, Boolean& async)
at System.Web.Hosting.ISAPIWorkerRequest.FlushCachedResponse(Boolean isFinal)
at System.Web.Hosting.ISAPIWorkerRequest.FlushResponse(Boolean finalFlush)
at System.Web.HttpResponse.Flush(Boolean finalFlush)
at System.Web.HttpResponse.Flush()
at ResumeDownload.ProcessDownload(String fileName, String headerFileName, String fileMimeType)
at FileDownloader.Page_Load(Object sender, EventArgs e)
我的网站是一个移动网站,周围有无数不同的移动浏览器,有不同的下载方法。它们通常也通过运营商网关连接,所以我猜这与客户机断开连接或WAP代理问题有关。
我要做的是如何阻止这种情况的发生。我不想试一下CATC和iGonore。我读过关于
catch (ThreadAbortException ex)
和
Thread.ResetAbort();
但无法成功地将其实现到类中。有人用类似的代码来保护吸血吗?