PRB: System.Threading.ThreadAbortException Error Message When You Use Server.Transfer in HTTPHandler in an ASP.NET Application (817266)
The information in this article applies to:
- Microsoft ASP.NET (included with the .NET Framework 1.1)
- Microsoft ASP.NET (included with the .NET Framework) 1.0
SYMPTOMSWhen you use a Server.Transfer method in HTTPHandler to transfer the control from one page to another in an
ASP.NET Web application, you
may receive the following error message: System.Threading.ThreadAbortException: Thread was being
aborted. at System.Threading.Thread.AbortInternal() at
System.Threading.Thread.Abort() at System.Threading.Thread.Abort(Object
stateInfo) at System.Web.HttpResponse.End() at
System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm) CAUSEWhen you call Server.Transfer, ASP.NET internally calls
the Server.Execute method to transfer the control, and calls the Response.End method to end the processing
of the current page. Response.End ends the page execution and calls
the Thread.Abort method. The Thread.Abort method causes the ThreadAbortException error message to appear.WORKAROUNDTo work around this problem, use Server.Execute instead of
Server.Transfer in the ProcessRequest method of HTTPHandler. The modified
ProcessRequest method is as follows: Visual C# .NET Sample Code
public void ProcessRequest(HttpContext context)
{
try
{
context.Server.Execute("WebForm1.aspx");
}
catch(System.Exception e)
{
context.Response.Write(e.StackTrace);
context.Response.Write(e.ToString());
}
} Visual Basic .NET Sample Code
Public Sub ProcessRequest(ByVal context As HttpContext) _
Implements IHttpHandler.ProcessRequest
Try
context.Server.Execute("WebForm1.aspx")
Catch e As Exception
context.Response.Write(e.StackTrace)
End Try
End Sub STATUS This
behavior is by design.REFERENCES For additional information,
click the following article numbers to view the articles in the Microsoft
Knowledge Base: 312629
PRB: ThreadAbortException Occurs If You Use Response.End, Response.Redirect, or Server.Transfer
320439 PRB: "Error Executing Child Request" Error Message When You Use Server.Transfer or Server.Execute in ASP.NET Page
224363 Using the Server.Execute Method
Modification Type: | Major | Last Reviewed: | 5/5/2003 |
---|
Keywords: | kberrmsg kbThread kbWebForms kbConfig kbprb KB817266 kbAudDeveloper |
---|
|