A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll

前端 未结 2 1265
南旧
南旧 2021-01-01 15:48

I am working on an asp.net application.. when I try to compile and run the application; it runs successfully.

But when I try to debug the application it gives me err

2条回答
  •  被撕碎了的回忆
    2021-01-01 16:24

    I had this exception thrown in my asp.net app, and found this forum post:

    PRB: ThreadAbortException Occurs If You Use Response.End, Response.Redirect, or Server.Transfer http://support.microsoft.com/default.aspx?scid=kb;en-us;312629

    This make sense as I was redirecting on a page right before anything was rendered (expected behavior by the way)

    Workaround by MS to suppress any exceptions:

    To work around this problem, use one of the following methods:

    • For Response.End, call the HttpContext.Current.ApplicationInstance.CompleteRequest method instead of Response.End to bypass the code execution to the Application_EndRequest event.

    • For Response.Redirect, use an overload, Response.Redirect(String url, bool endResponse) that passes false for the endResponse parameter to suppress the internal call to Response.End. For example: Response.Redirect ("nextpage.aspx", false);

    • For Server.Transfer, use the Server.Execute method instead.

    If you use this workaround, the code that follows Response.Redirect is executed. For Server.Transfer, use the Server.Execute method instead.

提交回复
热议问题