ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 17th, 2002, 04:11 PM
mdg mdg is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: San Francisco
Posts: 2 mdg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question ASP redirects and HTTP referers

I'm creating an intranet application using ASP and Access. Until they have logged in, if users request any other page in the application, they are redirected to the login page. After they log in, I would like to redirect them back to the page they originally requested.

I tried using Request.ServerVariables("HTTP_REFERER") to capture the URL of the page they had originally requested, but it returns the URL for the page they were on when they made the request, not for the page they requested (which redirected them to the login page). Is there a way to capture the URL of the page which redirected them to the login page?

Is there a better way to do this?

Reply With Quote
  #2  
Old October 18th, 2002, 05:12 AM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Send a message via Yahoo to fakker
hey mdg welcome to the devarticles forum!!

so, if I was not logged in to your website, and clicked say "membersarea.asp" it would redirect me to the login.asp page.....

what you could do is pass a variable called "referringpage" over with the redirect to login.asp.

so the code might look like:

IF user is not logged in THEN
response.redirect ("login.asp?referringpage=membersarea.asp")
END IF

then in your login.asp page, you would have the login script, and if all is ok with the username and password, you would simply get the referring page, and redirect the user back to it.


IF login is ok THEN
response.redirect "" & request.querystring("referringpage") & ""
END IF

that should work ok. So the above statement would then redirect the user to the referring page, in this case "membersareas.asp".

Hope that helps!
__________________
Matt 'Fakker' Facer

mattfacer.com

Reply With Quote
  #3  
Old October 18th, 2002, 07:11 AM
adurstew's Avatar
adurstew adurstew is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Charlotte, NC
Posts: 114 adurstew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 33 sec
Reputation Power: 17
Send a message via AIM to adurstew Send a message via Yahoo to adurstew
Another Idea

Another idea would be to use a session variable. If the session variable = "" then the person isn't logged in and you redirect them to login.asp

For example:

When logging in set a unique id in the database to
Session("yoursession") = db_uniqueID

Then just look for it all the time using a script at the top of the page.

If Session("yoursession") = "" Then
Response.Redirect "login.asp"
End If

hth,
__________________
Andrew J Durstewitz
ASP.NET,VB.NET,SQL Developer

http://madashellnc.blogspot.com

Reply With Quote
  #4  
Old October 18th, 2002, 07:33 AM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Send a message via Yahoo to fakker
yeah, that's what I do as well.. once I've validated that the user is ok.... I set the following:

// security = 1 means they are logged in. otherwise it's 0
Session("securityOK") = 1
Session("fname") = first name from the DB of the user logged in.

I use the fname variable so that I dont need to keep accessing the DB to say "hello <% fname %>"


Like adurstew said, it's then dead simple to check if a user has access to a page!

Reply With Quote
  #5  
Old October 18th, 2002, 01:00 PM
adurstew's Avatar
adurstew adurstew is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Charlotte, NC
Posts: 114 adurstew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 33 sec
Reputation Power: 17
Send a message via AIM to adurstew Send a message via Yahoo to adurstew
If you want to get really lazy (like me) then you write an asp page that does the Session OK check and just setup an include file on all the rest of the pages.

Then if you need to update the Session checking you only have to update the one file...

Laziness tends to be where good ideas come from...heh...

hth,

Reply With Quote
  #6  
Old October 21st, 2002, 10:06 AM
mdg mdg is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: San Francisco
Posts: 2 mdg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you.

Thanks so much, these are really good ideas.

Reply With Quote
  #7  
Old October 21st, 2002, 02:37 PM
adurstew's Avatar
adurstew adurstew is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Charlotte, NC
Posts: 114 adurstew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 33 sec
Reputation Power: 17
Send a message via AIM to adurstew Send a message via Yahoo to adurstew
glad i could help )

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > ASP redirects and HTTP referers


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap