HttpContext.ThreadAbortOnTimeout 属性


获取或设置一个值,此值指示 ASP.NET 运行时是否应在请求超时时,调用为该请求提供服务的线程上的 Abort()Gets or sets a value that specifies whether the ASP.NET runtime should call Abort() on the thread that is servicing this request when the request times out.

 property bool ThreadAbortOnTimeout { bool get(); void set(bool value); };
public bool ThreadAbortOnTimeout { get; set; }
member this.ThreadAbortOnTimeout : bool with get, set
Public Property ThreadAbortOnTimeout As Boolean



如果在线程超时时调用 Abort(),则为 true;否则为 falsetrue if Abort() will be called when the thread times out; otherwise, false. 默认值为 trueThe default is true.


在使用属性实现协作取消的处理程序和模块中 HttpRequest.TimedOutToken ,你可能希望禁用在请求超 Thread.Abort 时时 ASP.NET 默认执行的行为。如果将此属性设置为, false 则可帮助您确保在不中断 ASP.NET 的情况下运行取消和清理例程。In handlers and modules that are using the HttpRequest.TimedOutToken property to implement cooperative cancellation, you might wish to disable the Thread.Abort behavior that ASP.NET performs by default when a request times out. Setting this property to false can help you make sure that cancellation and cleanup routines will run without being interrupted by ASP.NET.

如果将此属性设置为 false ,则在发生超时时,ASP.NET 不会自动显示 "请求超时" 错误页。If you set this property to false, ASP.NET will not automatically display a "Request timed out" error page when a timeout occurs. 应用程序负责正确设置响应内容。The application is responsible for setting the response content appropriately.