Asp.Net 范围特定请求 ThreadAbortException 线程被中止

发布于 2024-09-07 17:58:57 字数 1747 浏览 3 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-09-14 17:58:57

如果您使用

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文