Solved

Redirect to referrer page

Posted on 1998-09-01
7
168 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?
0
Comment
Question by:dejthor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 

Expert Comment

by:matthewallum
ID: 1270044
try this _before_ any HTML code....

if the session varible is false (or whatever)

   Response.Redirect "newURL"


0
 
LVL 1

Author Comment

by:dejthor
ID: 1270045
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
 
LVL 8

Expert Comment

by:jbirk
ID: 1270046
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!

 
LVL 28

Expert Comment

by:sybe
ID: 1270047
Use this before you write anything else in the ASP:
<%
If Not Session("whatever") Then
  Response.redirect(Request.ServerVariables("HTTP_REFERER"))
End If
%>
0
 
LVL 1

Author Comment

by:dejthor
ID: 1270048
That would work if I knew the url the user came from.
0
 
LVL 8

Expert Comment

by:jbirk
ID: 1270049
HTTP_REFERER is the url the user came from.
-Josh
0
 
LVL 28

Accepted Solution

by:
sybe earned 10 total points
ID: 1270050
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question