Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

asp.net redirect issue

Posted on 2007-08-02
7
Medium Priority
?
175 Views
Last Modified: 2013-11-26
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?
0
Comment
Question by:dchau12
  • 4
  • 3
7 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19622161
Response.Redirect("Construction.ASPX")

Bob
0
 

Author Comment

by:dchau12
ID: 19625207
That doesn't work.   It immidiately throws an threading error.

"system.Threading.ThreadAbortException: Thread was being aborted"
0
 
LVL 96

Expert Comment

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

Bob
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 19625347
Is this inside a Try/Catch block?

Bob
0
 

Author Comment

by:dchau12
ID: 19625375
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19625407
The second False argument is telling the processor not to end the Response, so that everything after this will be processed.

Bob
0
 

Author Comment

by:dchau12
ID: 19625575
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question