When an ASP.NET System.Web.HttpResponse.End() is called, the current thread is aborted?

前端 未结 5 495
你的背包
你的背包 2020-12-31 03:56

when a System.Web.HttpResponse.End() is called a System.Thread.Abort is being fired, which i\'m guessing is (or fires) an exception? I\'ve got some logging and this is being

5条回答
  •  孤独总比滥情好
    2020-12-31 04:47

    There's nothing inherently ungraceful about an exception recursing up your stack to stop the current execution. Certainly no more than you throwing an exception and catching it at some lower place in your exception.

    I'd look at filtering it from your logging. If you're using the ASP.Net health monitoring you can configure/map each exception to a given provider (event log, mail, etc) to control whether you get a notification for threadabort exceptions or not. If it's custom logging then I'd just add an if to check for it.

    Note that you can't eat a ThreadAbortException so even if your logging code is doing something like catch(Exception e) { // log exception and then do not throw again } the ThreadAbortException will still be raised again by the framework once your catch block exits.

提交回复
热议问题