Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

conditional redirects based on login status and other conditions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith G Hicks - 06 Mar 2008 20:53 GMT
asp.net 2.0

I have a login control on a Login.aspx page. If a user tries to go to a page
and is not authenticated and should be then he's taken to the login page.
The login control has a property (DestinationPageUrl) for the page to go to
on successful login. But I need more than one destination depending on the
page that took the user to the Login page and where he may have been going
when the login page came up.

Examples:

1. If the user is on the default page and clicks the Login link then I want
him to be take back to the Default page.

2. If he clicks a link on the default page that is supposed to take him to a
page that requires authentication, then the login page should appear and
then after logging in correctly, he should continue on to the page desired.

I'm pretty sure that with little or no code, the login control handles the
above on it's own. However, there are other situations that I cannot seem to
solve and if htey are handled, probably negate the automated redirect stuff
that the login control does. Not sure though.

3. The user is not logged in and is on a page other than the default page
(ListOfPeople.aspx). This page does NOT require him to be logged in. There
is a  link ("Edit my Info") on that page that takes the user to one of 2
pages that DO require him to be logged in. This one is a little complicated.
If the user is not logged in when he clicks the "Edit my Info" link, then he
needs to be taken to the login page. After logging in, one of 2 things
should happen. First, if he's previously located himself in a list of people
(whehter he has or not is stored in one of my sql tables), then he is taken
to page EditMyInfo.aspx but if he's not already found himself in the
listthen he's to be taken to FindMyself.aspx.

4. This is similar to item #3 except that he's already logged in. When the
user is on the ListOfPeople.aspx page, I still need to take him to the
EditMyInfo.aspx page or the FindMyself.aspx page depending on whehter or not
he's previouslly found himself in the list.

In either of situations 3 & 4, if he does not log in succesfully, he needs
to be take back to the Default.aspx page

I hope I explained this well enough. I'm not sure if all this has to happen
with Redirects in VB or if it can be done in another way. I'm also not sure
if I need to set session variables, query strings or something else to
indicate where the user came from and where he intended on goiogn so that
any If/Else/Endif VB code I write will cuase the user to end up in the right
place. I'm just not sure of the best way to handle this in asp.net.

Thanks,

Keith
Keith G Hicks - 07 Mar 2008 02:45 GMT
Well I ended up handling this with a combination of session variables and
query string variables. It seems to work fine so far. I'm still open to
ideas because I'm sure others have already created this wheel many times.
I'm far from an expert at this point so I'm sure I could be doing things
better.

Keith

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.