Link to home
Start Free TrialLog in
Avatar of dejthor
dejthor

asked on

Redirect to referrer page

I am using a combination of javascript and Server side VBscript on an Active Server Page. Based on a session valiable, If false, I want to redirect to the page they came from.
Any Ideas?
Avatar of matthewallum
matthewallum

try this _before_ any HTML code....

if the session varible is false (or whatever)

   Response.Redirect "newURL"


Avatar of dejthor

ASKER

Sure, I can redirect to a specific URL, However, i want to redirect them to the page they came from. That page is unknown.
In JavaScript you can always use history.go(-1) but I don't know anything about ASP...
-Josh
Avatar of sybe
Use this before you write anything else in the ASP:
<%
If Not Session("whatever") Then
  Response.redirect(Request.ServerVariables("HTTP_REFERER"))
End If
%>
Avatar of dejthor

ASKER

That would work if I knew the url the user came from.
HTTP_REFERER is the url the user came from.
-Josh
ASKER CERTIFIED SOLUTION
Avatar of sybe
sybe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial