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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Response.Redirect Problem

Status
Not open for further replies.

dwg23

Technical User
Oct 21, 2002
151
US
Hello,
I am writing a login script for my companys site and am having a problem.

I want users to be directed back to the login page if they haven’t logged in.
At the top of the page called index I have placed the following code.

<%if Session("CustomerType") <> "WMQ" and _
Session("CustomerType") <> "AFF" then
Response.Clear
Response.Redirect("op/login.asp?Access=op/index.asp")
end if %>

This results in the page cannot be displayed and the following in the address bar.

Notice the two “op” s in the line.

If I add a / before the first op in the redirect statement I get this.


If I leave the / in front of the first op and add a / before the second op I get this in the address bar and no page displayed.


This should be a no brainer but I can’t seem to get it right.

Thanks
DWG
 
probably you have some virtual directory problem.
is your site root correct?
QatQat

Life is what happens when you are making other plans.
 
It's not clear to me how you get to index.asp in the second two examples, as there is no redirect to this in your sample code. Is your logon test in index.asp, and you are passing the test and just staying in that file?

If you hadn't shown the two examples with the slash, I would say that index.asp and logon.asp are in the same directory, so your redirect should look like:

Response.Redirect("login.asp?Access=op/index.asp")

 
It's not clear to me how you get to index.asp in the second two examples, as there is no redirect to this in your sample code. Is your logon test in index.asp, and you are passing the test and just staying in that file?

If you hadn't shown the two examples with the slash, I would say that index.asp and logon.asp are in the same directory, so your redirect should look like:

Response.Redirect("login.asp?Access=index.asp")

No need to refer to op in any way if everything resides in that directory.
 
QatQat,
Not sure what you are asking when you ask is the site root correct.

mmcgon,
Yes both of the files are in the same directory.
If I use your example of :

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%Response.Buffer = true%>
<%if Session("CustomerType") <> "WMQ" and _
Session("CustomerType") <> "AFF" then
Response.Redirect("login.asp?Access=op/index.asp")
end if %>

I get page cannot be found and this in the address bar:

If I use the other example of:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%Response.Buffer = true%>
<%if Session("CustomerType") <> "WMQ" and _
Session("CustomerType") <> "AFF" then
Response.Redirect("login.asp?Access=index.asp")
end if %>

I get a blank page and this in the address bar.

To further help, I have a link on the home page to
To the index page of the secure area which is in the directory op, so the full url of it would be At the top of op/index.asp is the redirect that I want them to be redirected to the login page at /op/login.asp.

Thanks
dwg
 
Where does the Session("CustomerType") get set? Presumably in login.asp. If so, remember that all code processing finishes on the server before the page is served. The usual solution is to set a dummy session variable at the end of your login page code, and test for it at the beginning. If it exists then do your login tests and redirect as needed. If it doesn't exist show the input form and get the username, passsword etc. The action method for the form is then processed by itself:
<form method="post" action="login.asp">

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top