Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 9th, 2007, 03:10 PM
Authorized User
 
Join Date: Jan 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Redirection From Admin page

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

 
Old January 9th, 2007, 03:33 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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/QuickStar...y/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.
 
Old January 10th, 2007, 03:38 PM
Authorized User
 
Join Date: Jan 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old January 10th, 2007, 05:06 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate database entry redirection error page EmWebs Dreamweaver (all versions) 3 December 29th, 2006 10:17 AM
Duplicate database entry redirection error page EmWebs Access ASP 0 December 27th, 2006 12:54 PM
PHP and Page Redirection joanncae BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 May 21st, 2004 11:07 AM
Automatic redirection once page with SWF loaded Burton HTML Code Clinic 1 September 13th, 2003 06:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.