2011-06-02 16 views
10

İşte benim kodudur. İşte ASP.NET Response.Redirect() Hata

hatadır:

"System.Threading.ThreadAbortException: Thread was being aborted.\r\n at System.Threading.Thread.AbortInternal()\r\n at System.Threading.Thread.Abort(Object stateInfo)\r\n at System.Web.HttpResponse.End()\r\n at System.Web.HttpResponse.Redirect(String url, Boolean endResponse)\r\n at System.Web.HttpResponse.Redirect(String url)\r\n

bu hata oluştuğu neden kimse bana söyleyebilir misiniz?

cevap

19

Sadece hareket olabilir ....

Response.Redirect("~/Membership/UserRegistration.aspx"); 

... deneyin/catch bloğu dışında veya aşağıdaki John S. Reid's newer solution deneyebilirsiniz:

Response.Redirect(url) ThreadAbortException Solution


by John S. Reid
March 31, 2004
(edited October 28, 2006 to include greater detail and fix some inaccuracies in my analysis, though the solution at it's core remains the same)

... aşağı atlayarak .. aşağı atlayarak

.

The ThreadAbortException is thrown when you make a call to Response.Redirect(url) because the system aborts processing of the current web page thread after it sends the redirect to the response stream. Response.Redirect(url) actually makes a call to Response.End() internally, and it's Response.End() that calls Thread.Abort() which bubbles up the stack to end the thread. Under rare circumstances the call to Response.End() actually doesn't call Thread.Abort(), but instead calls HttpApplication.CompleteRequest(). (See this Microsoft Support article for details and a hint at the solution.)

... ...

- Ben kaydırma olmaz bu yüzden SO içeride sınırları sığdırmak için biçimlendirme kodu güncellenmiştir.

+0

Hey, o nereden "* Eğer Response.Redirect bir çağrı (URL) ... * yaptığınızda ThreadAbortException atılır", hatırlıyor musun diyor sizin blok alıntı? aslında birden fazla kişi 'tarafından çok aşırma oldu çünkü sorun Google üzerinden bu alıntının orijinal kaynak bulmaya çalışıyorum yaşıyorum: /' –

+0

Bu ben ile gelebilir iyi bağlantıdır, ancak orijinal yazarın eseri değil ya da, bir yazar olarak "John S. Reid" yazıyor, 31 Mart, 2004 * itibaren: https://derekreynolds.wordpress.com/2009/10/27/using-response-redirect/. Orijinal makale şimdi de gitmiş gibi görünüyor. –

+3

The Way Back Machine için Tanrıya şükür, tekrar * orijinal * kaynağını buldum: [Response.Redirect (url) ThreadAbortException Solution] (https://web.archive.org/web/20120120110234/http://www.c6software com/makaleler/ThreadAbortException.aspx). –

İlgili konular