Well, most of you who have tried out the combination must have been stuck with a weird error of "Thread was being aborted" and must have wondered what has a thread got to do with Response.redirect?
Well, to answer your question here goes:-
A thread is executing your application in terms of ASP.NET worker process , when you call Response.Redirect(URL);
In your code then to redirect to the new URL specified by you ASP.NET framework must be told to stop the current execution of the page and to transfer the execution to the URL page specified in the method call.
This is done in a 2 way step :-
1) Response.End() is called internally by Response.Redirect to stop the current execution and the ThreadAbortException is thrown.
2) .NET framework will call catch “ThreadAbortException” and stop current execution and start executing the new page.
Asp.net framework catches the Redirect method’s exception, aborts the thread and use a new thread for execution of to be redirected page.
Solution :- The way to get over this problem is to specify Response.Redirect(URL,false) , this will tell .NET framework not to stop the execution of the current thread and hence the error will be resolved.
“ThreadAbortException” is a special kind of an exception even if you catch it in a catch block even then it will be raised again at the end of the catch block. When this exception is raised, the runtime executes all the finally blocks before killing the thread.
– UVN Pardha Saradhi