2013-02-13 3 views
0

안녕하세요 난 다른 나의 현재 페이지에서 리디렉션하려고 리디렉션하지 않습니다ASP.Net은

Thread was being aborted. 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Threading.ThreadAbortException: Thread was being aborted. 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 


[ThreadAbortException: Thread was being aborted.] 
    System.Web.HttpContext.InvokeCancellableCallback(WaitCallback callback, Object state) +298 
    System.Web.Util.<>c__DisplayClass1.<WrapContinuation>b__0() +37 
    System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.<.cctor>b__3(Object state) +37 
    System.Web.<>c__DisplayClass7.<Post>b__6() +15 
    System.Web.Util.SynchronizationHelper.SafeWrapCallback(Action action) +91 

실수는 페이지와 생성하는 코드에 이것은 :

protected void Button1_Click(object sender, EventArgs e) 
{ 
    Response.Redirect("/seller/ven_mainwin/recharge/recharge.aspx"); 
} 
+1

가능한 중복 ([내가 Response.Redirect를()를? 실행할 때 나는 발생한 예외를 이유는 무엇입니까] http://stackoverflow.com/questions/1364645/why- do-i-get-a-throw-exception-when-i-run-response-redirect) 및 [Response.Redirect는 System.Threading.ThreadAbortException을 발생시킵니다.] (http://stackoverflow.com/questions/2777105/response-redirect -causes-system-threading-threadabortexception/2777204 # 2777204) – jrummell

답변

1

Response.Redirect이 ThreadAbortException을 유발합니다.

대다수의 경우이 문제는 무시해도됩니다.

protected void Button1_Click(object sender, EventArgs e) 
{ 
    try{ 
     Response.Redirect("/seller/ven_mainwin/recharge/recharge.aspx"); 
    } 
    catch (System.Threading.ThreadAbortException e){ 
     // do nothing. This exception can be ignored. 
    } 

} 

Joel Fillmore points out that this is the correct design pattern

Response.Redirect(url, false); 
Context.ApplicationInstance.CompleteRequest(); 
+0

나는 예외 자체를 무시할 수 있다고 말하고 싶지만 예외는 먹어서는 안된다. – rossisdead