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 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 framework must be notified about a redirection request. 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 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

Saturday, November 13, 2004


I have completed my MCAD.Net certification today...:)
The exams I took includes Asp.Net(Vb.Net), XML Web Services(Vb.Net), Windows App.(in C#).

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