Jump to content



Photo

ASP redirect to previous page


  • Please log in to reply
6 replies to this topic

#1 Rohdekill

Rohdekill

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 06-July 05
  • Location: Earth

Posted 09 January 2006 - 22:31

Is it possible to utilize ASP's Response.Redirect command to return to the previously viewed page?

I have a member's sign in box on all of my front-end pages. If the authentication page fails to validate the user name and password I wish it to return to the page the user was last at. I have every page's sign in form's action referring to one validation page.

If this is possible, can someone paste the code for me?

Much thanks!


#2 username();

username();

    Neowinian

  • Joined: 09-January 05
  • Location: Ontario, Canada

Posted 09 January 2006 - 22:34

Well, set the previous page to add a ?previouspage=blank.asp to the login page URL and access it using the Request object.

But the real question here is why are you using ASP when ASP .net 2.0 is FREE and there is a GOOD free IDE for it from Microsoft (Visual Web Developer Express @ msdn.microsoft.com).

#3 Josh

Josh

    Neowinian Senior

  • Joined: 09-August 04
  • Location: Felton, Delaware

Posted 10 January 2006 - 02:35

Well, set the previous page to add a ?previouspage=blank.asp to the login page URL and access it using the Request object.

But the real question here is why are you using ASP when ASP .net 2.0 is FREE and there is a GOOD free IDE for it from Microsoft (Visual Web Developer Express @ msdn.microsoft.com).


Just do a Response.Redirect(Server.RequestVariables("HTTP_REFERER"))

#4 +mrbester

mrbester

    Be seeing you...

  • Joined: 10-April 02
  • Location: Brighton, Land of the South Saxons, Albion

Posted 10 January 2006 - 10:53

But the real question here is why are you using ASP when ASP .net 2.0 is FREE

Because OP may have something in Classic and doesn't want / need to convert the lot? Just because it can be done doesn't mean it should be done.

MyServerGuy: would work nicely until someone blocks referrer (and it's Request.ServerVariables)...

As there is a form (posted I presume as it is a login form) add a hidden field with the value set to Request.ServerVariables("SCRIPT_NAME") so you don't use a hardcoded value and retrieve that

#5 Josh

Josh

    Neowinian Senior

  • Joined: 09-August 04
  • Location: Felton, Delaware

Posted 10 January 2006 - 18:22

busted by mrbester :D it was a rush job in between errand runs. And you're right, it would... and referer is blocked quite a bit now, or not transferred at all (in the instance of HTTPS). You would be better off with a hidden form field that grabs the script name.

#6 uratewl

uratewl

    Neowinian

  • Joined: 23-June 04

Posted 14 January 2006 - 03:41

You could use something like this:

<%If Password <> Password Then%>
<script language="javascript">
history.go(-1);
</script>
<%End If%>

#7 +mrbester

mrbester

    Be seeing you...

  • Joined: 10-April 02
  • Location: Brighton, Land of the South Saxons, Albion

Posted 16 January 2006 - 10:04

See my previous post and replace referrer with JavaScript.
You can't rely on the client whatsoever. You could have set up a JavaScript bounce with a meta refresh fallback and you'd still lose out (especially if they used HTTP_REFERER as the data). It's something you want the server to do, so let the server do it. At least you have control there.
Oh, and language="javascript" is so 1997. It's type="text/javascript" nowadays...



Click here to login or here to register to remove this ad, it's free!