Asp.Net 范围特定请求 ThreadAbortException 线程被中止
我正在使用 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();
但无法成功地将其应用到课堂上。有没有人使用类似的代码来保护水蛭?
I am using class at http://pastebin.com/aK0zcxMN ( a version of http://dotnetslackers.com/articles/aspnet/Range-Specific-Requests-in-ASP-NET.aspx) to protect downloads from leech and provide resume. It works fine but every now and then i get
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)
My site is a mobile site and there are gazillions of different mobile browsers around with different approaches to downloads. They also usually connects via operators gateway so I guess it is something to do with client disconnection or wap proxy problem.
What i am trying to do is how can i stop this happening. I don't want to try catc and igonore it. I've read about
catch (ThreadAbortException ex)
and
Thread.ResetAbort();
but could not implement it in to the class successfully. Has anyone used similar code to protect leeching?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用
Response.Redirect("Some URL");
则尝试此
Response.Redirect("Some URL",false);
在这种情况下,响应将不会end 并且您不需要使用 catch 块来处理它。但请确保您的流程不会受到干扰。
if you are using
Response.Redirect("Some URL");
then try this
Response.Redirect("Some URL",false);
In this case the responce will not end and you dont need to handle it using catch block. But make sure your flow will not disturb.