Thursday, November 25, 2004

Internals of ‘Response.Redirect’

We use Response. Redirect to redirect to another webpage. Sometimes it throws ‘”Thread was being aborted” message.

This might be because the page is executing by a thread on which asp.net worker process contains. And on some line in our 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 uses 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'.

This exception is raised because Response.Redirect method internally calls Response.End method which raises this exception and the page processing terminates. Response.End raises this exception indirectly through calling Thread.Abort which raises this exception directly.

Another thing we can do is use the overloaded version of Redirect:

Response.Redirect("default.aspx", false);

Happy programming

Comments:
WrvOxo [url=http://www.outletmonclerspacciopiumini.com/]Moncler Outlet[/url] JllLky http://www.outletmonclerspacciopiumini.com/

GfoFcj [url=http://www.vnikefree.com/]Nike Free V2[/url] KxiAys http://www.vnikefree.com/

BvhAgu [url=http://www.outletmonclerspaccio.com/]Moncler Piumino[/url] GyuLni http://www.outletmonclerspaccio.com/

ShoEsa [url=http://www.Jakker2canadagoose.com/]Canada Goose Canada[/url] VppScg http://www.Jakker2canadagoose.com/

UmmJam [url=http://www.parkajakker4canadagoose.com/]Canada Goose Jakker[/url] HpqAyx http://www.parkajakker4canadagoose.com/

KuhXkq [url=http://www.jakke2canadagoose.com/]Canada Goose Jakke[/url] XvzKiz http://www.jakke2canadagoose.com/

UfqRpi [url=http://www.canadagoosefromcanada.com/]Goose Jakker[/url] OxeIba http://www.canadagoosefromcanada.com/
 
Post a Comment

This page is powered by Blogger. Isn't yours?