Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Direct user to correct page upon login...help

Status
Not open for further replies.

Culley

Technical User
Jan 23, 2007
4
US
I've created a secure login site. Everything works fine except for one thing... the redirect.

I want to redirect users to the correct page they are accessing (say they're just clicking a link they've bookmarked to a particular page in the secure site) rather than forcing them to navigate in from a default "login successful" page.

In each secure page, I have this include file:

<%
if Session("valid") = "" Then
Response.Redirect ("login_new.asp?r=" & Server.URLEncode(Request.ServerVariables("URL") & Request.Querystring))
end if
Session.Timeout=120
%>

My login script looks like this:

<form name="login" method="POST" action="verify_new.asp">
<p>Username:
<input type="text" name="UserName">
</p>
<p>Password:
<input type="password" name="Password">
</p>
<p><input type="hidden" name="redirect" value="<%=Request.Querystring("r")%>">
<input type="submit" name="Submit" value="Submit">
</p>
</form>

My verify page looks like this:

<%
dim username, password, sRedirect

sRedirect = Request.Form("redirect")
If sRedirect = "" then
sRedirect = "default.asp"
end if

...(lots of code)...

' if both username and pass are valid, create session ID
if Session("Valid") = Request("username") then
response.redirect sRedirect
end if
%>

If I create a url like this: everything functions just fine. However, if I create a url like this: the script always returns a page cannot be found error.

I've looked through my code, but I don't see that I've coded a bum link.

The error url returned looks like this:
And, it's a simple 404 error.

I suspect it has something to do with how I create the stored url in this line:
Response.Redirect ("login_new.asp?r=" & Server.URLEncode(Request.ServerVariables("URL") & Request.Querystring))

Any thoughts or suggestions?

Thanks,

Culley
 
I believe I already have it scripted that way:

Response.Redirect ("login_new.asp?r=" & Server.URLEncode(Request.ServerVariables("URL") & Request.Querystring))

Or is that not where you meant?

 
Okay, I'm dumb, I figured it out.

I just spelled out the full url to the login_new.asp path.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top