Response.Redirect

K

Kerri

Hi,

I have do some Redirects in my applitcaion.

For example, when the use rhas logged in successfully I
redirect them to a different page.

In my Redirect all I was doing was a..

Response.Redirect("SomePage.aspx")

When I used above I got below error.

2) Exception Information
*********************************************
Exception Type: System.Threading.ThreadAbortException
ExceptionState:
System.Web.HttpApplication+CancelModuleException
Message: Thread was being aborted.
TargetSite: Void AbortInternal()
HelpLink: NULL
Source: mscorlib

StackTrace Information
*********************************************
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.End()
at System.Web.HttpResponse.Redirect(String url, Boolean
endResponse)
at System.Web.HttpResponse.Redirect(String url)



I have now changed all my Redirects to be..

Response.Redirect("MyPage.aspx", False)

I use False everywhere as I don't want to ever end the
execution of my page.

I have 2 questions-:

(i) Why was I getting above error. Do I have to pass in a
boolean also to my Response.Redirect?
(ii) When would I use True. Surely I will never want to
finish executing the page I am on so it will always be
False???

Any advice on this is much appreciated.
 
A

AlexB

..Redirect has two overloads, which you've specified. I've
gotten the error that you've indicated when I try to step
into the call when I'm debugging, but not when it executes
normally.
 
C

Christopher Bova

I've run across this before- the exception you are dealing
with can best be thought of not as an error but as a
notification that request processing is ending because the
user is being redirected. It's completely safe to just
ignore it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top