We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Redirect to referrer page

dejthor
dejthor asked
on
Medium Priority
184 Views
Last Modified: 2008-02-01
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?
Comment
Watch Question

try this _before_ any HTML code....

if the session varible is false (or whatever)

   Response.Redirect "newURL"


Author

Commented:
Sure, I can redirect to a specific URL, However, i want to redirect them to the page they came from. That page is unknown.

Commented:
In JavaScript you can always use history.go(-1) but I don't know anything about ASP...
-Josh

Commented:
Use this before you write anything else in the ASP:
<%
If Not Session("whatever") Then
  Response.redirect(Request.ServerVariables("HTTP_REFERER"))
End If
%>

Author

Commented:
That would work if I knew the url the user came from.

Commented:
HTTP_REFERER is the url the user came from.
-Josh
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.