asp.net redirect issue

If one of my session variables equals a particular value in the if clause, I want the code to go to the page I direct it to, and stop execution on the current page.  This is the code I have below:

If Session("MyStudyType") = "NonLongitudinal" Then
       Response.Redirect("Construction.ASPX", False)
End If

This condition is tripped, but it still executes the rest of the code on the page.  How do I get it to go to the page I direct it to go to without executing the rest of the code on the page?
dchau12Asked:
Who is Participating?
 
Bob LearnedCommented:
Is this inside a Try/Catch block?

Bob
0
 
Bob LearnedCommented:
Response.Redirect("Construction.ASPX")

Bob
0
 
dchau12Author Commented:
That doesn't work.   It immidiately throws an threading error.

"system.Threading.ThreadAbortException: Thread was being aborted"
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
Bob LearnedCommented:
This is too narrow of a view of your problem.  What is the bigger picture here?  What are you trying to do?

Bob
0
 
dchau12Author Commented:
Basically, if a particular flag is tripped, I do not want the user on a particular page, because the data wont support it.  So, I want to re-direct them to another page without continuing the execution.

This worked:

If Session("MyStudyType") = "NonLongitudinal" Then
   Response.Redirect("Construction.ASPX", False)
   Exit Sub
End If

but, you are right, the try/catch block directly after the redirect would work as well.
0
 
Bob LearnedCommented:
The second False argument is telling the processor not to end the Response, so that everything after this will be processed.

Bob
0
 
dchau12Author Commented:
I realized that, but when I replaced it with a true, it immidiatly threw a threading error.  so, the try catch or exit sub works.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.