Code to return to calling page

Discussion in 'ASP General' started by qaz, Jan 30, 2005.

  1. qaz

    qaz Guest

    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.
     
    qaz, Jan 30, 2005
    #1
    1. Advertising

  2. qaz

    Evertjan. Guest

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

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
     
    Evertjan., Jan 30, 2005
    #2
    1. Advertising

  3. qaz

    qaz Guest

    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." <> wrote in message
    news:Xns95EE72D9D3E80eejj99@194.109.133.29...
    > 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
    > %>
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Replace all crosses with dots in my emailaddress)
    >
     
    qaz, Jan 30, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fred Armitage
    Replies:
    2
    Views:
    3,428
    Sherif ElMetainy
    Aug 26, 2003
  2. ack95
    Replies:
    0
    Views:
    558
    ack95
    Mar 3, 2006
  3. wl
    Replies:
    2
    Views:
    606
    Dimitri Maziuk
    Mar 5, 2004
  4. Greenhorn
    Replies:
    15
    Views:
    884
    Keith Thompson
    Mar 6, 2005
  5. GAH
    Replies:
    0
    Views:
    521
Loading...

Share This Page