Friday, June 17, 2011

'Thread is being aborted' when using Response.Redirect

Issue :'Thread is being aborted' when using Response.Redirect

FIX: If you want to get rid of this exception, use Response.Redirect(url, false).

Cause explanation:
Your page is executing by a thread on which asp.net worker process contains. And on some line in your code, an instruction (Response.Redirect) wants to stop the execution because it must be stopped and asp.net framework must be notified about a redirection request.

Asp.net framework catches the Redirect method's exception, aborts the thread and use a new thread for execution of to be redirected page.

This occurs when you specify the second argument of Redirect method as True. Because this means to asp.net framework as 'Stop this page's execution ASAP and execute to be redirected page'.

Ref:http://p2p.wrox.com/asp-net-1-0-1-1-basics/5684-thread-being-aborted.html

No comments:

Post a Comment

Devops links

  Build Versioning in Azure DevOps Pipelines