• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

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?
0
dejthor
Asked:
dejthor
  • 2
  • 2
  • 2
  • +1
1 Solution
 
matthewallumCommented:
try this _before_ any HTML code....

if the session varible is false (or whatever)

   Response.Redirect "newURL"


0
 
dejthorAuthor 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.
0
 
jbirkCommented:
In JavaScript you can always use history.go(-1) but I don't know anything about ASP...
-Josh
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
sybeCommented:
Use this before you write anything else in the ASP:
<%
If Not Session("whatever") Then
  Response.redirect(Request.ServerVariables("HTTP_REFERER"))
End If
%>
0
 
dejthorAuthor Commented:
That would work if I knew the url the user came from.
0
 
jbirkCommented:
HTTP_REFERER is the url the user came from.
-Josh
0
 
sybeCommented:
dejthor,
I'll repeat my comment as my answer, because you say that it would work when you knew the url the user came from. The point is that you know it: Request.Servervariables("HTTP_REFERER") equals the url the user came from.

Try it, and you will see. If it does not work, then explain where is goes wrong, and someone might come up with a more satisfying answer.

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

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now