Response.Redirect and thread was being aborted error?

前端 未结 4 1944
广开言路
广开言路 2020-12-15 10:09

I had this error Thread was being aborted., this afternoon in my error log.

The code that caused this error is:

Response.Redirect(\"         


        
4条回答
  •  [愿得一人]
    2020-12-15 10:54

    I catch this exception and swallow it because ASP.NET is using exceptions for flow control rather than for an exceptional circumstance.

    try
    {
        // Do stuff.
    }
    catch(ThreadAbortException)
    {
        // Do nothing. ASP.NET is redirecting.
        // Always comment this so other developers know why the exception 
        // is being swallowed.
    }
    catch(OtherExceptionTypes ex)
    {
        // Log other types of exception.
    }
    

提交回复
热议问题