Subject: Redirection From Admin page
Posted By: stonesbg Post Date: 1/9/2007 2:10:38 PM
I have a website that has a login page.  I check to see if the user has security access for a particular page and if not i redirect to the admin page where he or she can log in.  What i am trying to figure out.  How can i get back to that original page?  Was thinking i would be able to take the web address from the address bar (don't know how to do this).  Then i just send this in the admin address bar.  That way i will be able to query string site= to get the original and then just redirect.  Is there an easier way and if not can someone tell me how to get the current web address for that page.  Has to be the one in the address bar as i do pass variables the webaddress so that i can use query string.

Thanks in advance

Reply By: Imar Reply Date: 1/9/2007 2:33:49 PM
Are you making use of .NET's membership and role features? Combined, these two offer almost all security stuff you need.

When you protect a page and a non-authenticated user tries to access it, she's redirected to the Login page automatically. After a successful login the user is taken back again.

See here: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/security/default.aspx for more information.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply By: stonesbg Reply Date: 1/10/2007 2:38:49 PM
Not i am not using .NET's membership and role features.  I am just checking the database to see if the user has been registered or not.  So after i check using session variables i might add to see if they are logged in or not.  If i redirect to the admin page but i want to be able to store the address somehow so that i will be able to go back to the original page when i am finished logging in

Reply By: Imar Reply Date: 1/10/2007 4:06:11 PM
Well, you asked if there was an easier way... The Membership and Role providers make authentication and authorization much easier, and are worth looking into.

Anyway, when you redirect to the Login page (done automatically with the .NET security features), you can pass in the current page in the QueryString (also done automatically with the .NET security features). You can do this by looking at Request.RawUrl

Then in the login age, when login succeeds you can take a look at the query string and redirect the user to the page they initially requested. (You never guess: this is also taken care of by the built-in security features.... ;-) OK, I'll stop now.... ;-) )

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.

Go to topic 54671

Return to index page 67
Return to index page 66
Return to index page 65
Return to index page 64
Return to index page 63
Return to index page 62
Return to index page 61
Return to index page 60
Return to index page 59
Return to index page 58