Sign in to follow this  
Followers 0

ASP redirect to previous page

7 posts in this topic

Posted

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!

Share this post


Link to post
Share on other sites

Posted

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).

Share this post


Link to post
Share on other sites

Posted

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"))

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Posted

You could use something like this:

<%If Password <> Password Then%>

<script language="javascript">

history.go(-1);

</script>

<%End If%>

Share this post


Link to post
Share on other sites

Posted

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...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.