如何看待未处理线程的异常在ASP.NET? [英] How to treat unhandled thread-exceptions in ASP.NET?
问题描述
ASP.NET应用程序应该怎样处理这些存在的一个非请求后台线程(由于错误)未处理的异常?
在默认情况下,这种异常会导致进程终止。 这是不能接受的一个ASP.NET工作进程的设置,因为同时运行的请求被中止,取消predictably。这也是一个性能问题。
By default, such exceptions cause the process to terminate. This is unacceptable in the setting of an ASP.NET worker process because concurrently running requests are aborted unpredictably. It is also a performance problem.
上的请求线程异常是不是一个问题,因为ASP.NET处理它们(通过显示错误页)。
Exceptions on a request thread are not a problem because ASP.NET handles them (by showing an error page).
在 AppDomain.UnhandledException
事件可观察到已发生了异常,但终端不能pvented在这一点上$ P $。
The AppDomain.UnhandledException
event allows to observe that an exception has occurred, but termination cannot be prevented at that point.
下面是一个摄制需要被粘贴到一个ASPX页面codebehind。
Here is a repro which needs to be pasted into an ASPX page codebehind.
protected void Page_Load(object sender, EventArgs e)
{
var thread = new Thread(() =>
{
throw new InvalidOperationException("some failure on a helper thread");
});
thread.Start();
thread.Join();
}
我知道的唯一的解决方案是不会让一个例外,逃未处理。是否有任何其他的,更具全球性和全面的解决方案呢?
The only solution I know of is to never let an exception "escape" unhandled. Is there any other, more global and thorough solution for this?
推荐答案
我觉得legacyUnhandledExceptionPolicy选项你的答案。
I think "legacyUnhandledExceptionPolicy" option is your answer.
导致ASP.NET未处理的异常崩溃的.NET 2.0 ; <一href="http://blogs.msdn.com/b/tom/archive/2007/12/04/unhandled-exceptions-causing-asp-net-to-crash-in-net-2-0.aspx" rel="nofollow">http://blogs.msdn.com/b/tom/archive/2007/12/04/unhandled-exceptions-causing-asp-net-to-crash-in-net-2-0.aspx
Unhandled exceptions causing ASP.NET to crash in .NET 2.0 ; http://blogs.msdn.com/b/tom/archive/2007/12/04/unhandled-exceptions-causing-asp-net-to-crash-in-net-2-0.aspx
这篇关于如何看待未处理线程的异常在ASP.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!