Code to return to calling page

Q

qaz

I have login links on a number of pages in my site. Some of the pages
expect variables on the querystring.

I want to be able to login from any of these pages. The login link
redirects me to a login page. I want to go back to the page I came from and
preserve the variables on the querystring.

Can anyone give me a short script to have a user return to a calling page
that preserves the querystring?

For what it is worth, I has used a simple response.redirect
request.servervariables("script_name") until I realized that I was losing
the querystring.

I also tried this, but it did not work - (it kept posting me to the login
page regardless of where I came from)

dim sQS
sQS = request.querystring

.... [code here ] ...

response.redirect request.servervariables("script_name") & sQS

Any help is appreciated.
 
E

Evertjan.

qaz wrote on 30 jan 2005 in microsoft.public.inetserver.asp.general:
dim sQS
sQS = request.querystring

... [code here ] ...

response.redirect request.servervariables("script_name") & sQS

You forget to insert the questionmark:

sQS = request.querystring
sSn = request.servervariables("url")
response.redirect sSn & "?" & sQS

=======================

A solution seems(!) to me to include on top of
every restricted page a "lockInclude.asp" include, that:

1 checks for the session variable "loggedinAs" not being empty,

2 if empty, displays a login form [followed by response.end],
submitting to the page, not just the include of course, itself.

The "lockInclude.asp" pseudocode, just the idea:

<%
if session("loggedinAs")<>"" then
' do nothing and go on with the calling page
' or perhaps do some householding tasks
elseif request.form("loginname")<>"" then
' Check the name/password for validity
' fill session("loggedinAs") only if check=ok
sQS = request.querystring
sSn = request.servervariables("url")
response.redirect sSn & "?" & sQS
else
%><html>..<form><input... <% ' ask for name/password
' build like a completely seperate login.asp, but is not
response.end
end if
%>
 
Q

qaz

Thanks, Evertjan. Yes, I was forgetting the "?". It's strange how you can
look at something so much that you don't notice the obvious!!

Good idea on the lockInclude.asp. I think I will try it.

Thank you very much.

Evertjan. said:
qaz wrote on 30 jan 2005 in microsoft.public.inetserver.asp.general:
dim sQS
sQS = request.querystring

... [code here ] ...

response.redirect request.servervariables("script_name") & sQS

You forget to insert the questionmark:

sQS = request.querystring
sSn = request.servervariables("url")
response.redirect sSn & "?" & sQS

=======================

A solution seems(!) to me to include on top of
every restricted page a "lockInclude.asp" include, that:

1 checks for the session variable "loggedinAs" not being empty,

2 if empty, displays a login form [followed by response.end],
submitting to the page, not just the include of course, itself.

The "lockInclude.asp" pseudocode, just the idea:

<%
if session("loggedinAs")<>"" then
' do nothing and go on with the calling page
' or perhaps do some householding tasks
elseif request.form("loginname")<>"" then
' Check the name/password for validity
' fill session("loggedinAs") only if check=ok
sQS = request.querystring
sSn = request.servervariables("url")
response.redirect sSn & "?" & sQS
else
%><html>..<form><input... <% ' ask for name/password
' build like a completely seperate login.asp, but is not
response.end
end if
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top