我正在使用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 并忽略它。我读过关于
catch (ThreadAbortException ex)
和
Thread.ResetAbort();
但无法成功地将其实施到班级中。有没有人使用类似的代码来保护水蛭?