conditional redirects based on login status and other conditions


K

Keith G Hicks

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
 
Ad

Advertisements

K

Keith G Hicks

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
 

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