• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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