Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    Adelaide, Australia
    Posts
    472
    Thanks
    3
    Thanked 0 Times in 0 Posts

    script name full with querystring?

    hi there!
    i want to write the string of the page so the page of
    http://www.sample.com/sample/sample.asp?id=325
    the string will be
    sample/sample.asp?id=32

    but when i use Request.ServerVariables("SCRIPT_NAME") it just gives me sample.asp

    how do i get the query string as well (please note the query string is different each time as it is a redirect script)

    thanks

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Code:
    str = Request.ServerVariables("SCRIPT_NAME") & "?" & Request.QueryString
    Response.Write str
    or

    Code:
    str = Request.ServerVariables("SCRIPT_NAME") & "?" & Request.ServerVariables("QUERY_STRING")
    Response.Write str
    If you have this script, you can see all the available server variables and their values.

    Code:
    for each item in request.servervariables
      response.write item & "=" & request.servervariables(item) & "<br />" & vbcrlf
    next

  • #3
    Regular Coder
    Join Date
    Sep 2002
    Location
    Adelaide, Australia
    Posts
    472
    Thanks
    3
    Thanked 0 Times in 0 Posts
    if i response.redirect them [using the first one] of the str, it doesn't work.

    http://www.site.com/site/page.asp?lg...p?type=5&id=14

    the referer is http://www.site.com/site/view.asp?type=5&id=14

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Is there any error? Is the value of str correct? How about the other one?

  • #5
    Regular Coder
    Join Date
    Sep 2002
    Location
    Adelaide, Australia
    Posts
    472
    Thanks
    3
    Thanked 0 Times in 0 Posts
    No, there's no error.
    It just doesn't redirect to the second querystring (being id)
    Yes, str is correct and it doesn't work with the other one either.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Can you post the code and actual url to be redirect?

  • #7
    Regular Coder
    Join Date
    Sep 2002
    Location
    Adelaide, Australia
    Posts
    472
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Code:
    	if Request.QueryString = "" then
    	pagename = Request.ServerVariables("SCRIPT_NAME")
    	else
    	pagename = Request.ServerVariables("SCRIPT_NAME") & "?" & Request.QueryString
    	end if
    	Dim pagerefer
    	pagerefer = "login.asp?lg=nologin&referer="
    	pagerefer = pagerefer & pagename
    	response.redirect(pagerefer)
    then on login.asp
    Code:
    if request("referer") = "" then
    			Response.Redirect "default.asp"
    else Response.Redirect(request("referer"))
    end if

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    You should encode the URL to be redirected so that the querystring will be passed to the other page properly.
    Code:
    pagerefer = "login.asp?lg=nologin&referer="
    pagerefer = pagerefer & Server.URLEncode(pagename)
    response.redirect(pagerefer)

  • #9
    Regular Coder
    Join Date
    Sep 2002
    Location
    Adelaide, Australia
    Posts
    472
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Cheers mate

  • #10
    Regular Coder
    Join Date
    Sep 2002
    Location
    Adelaide, Australia
    Posts
    472
    Thanks
    3
    Thanked 0 Times in 0 Posts
    still doesn't worK?

  • #11
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Can you give more details. What's the value of request("referer") in login.asp?

    BTW, you should specify the intended request collection to avoid possible retrieval of different value. When collection is not specified, the server searches the collections in the following order: QueryString, Form, Cookies, ClientCertificate, then ServerVariables.

    Code:
    request.querystring("referer")
    Although QueryString is the first, it is a good habit to not rely on the default properties or methods of objects.

  • #12
    Regular Coder
    Join Date
    Sep 2002
    Location
    Adelaide, Australia
    Posts
    472
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I happened to not use QueryString in that instance, but thanks for the tip

    I response.wrote it and then i saw it only had the first string so i traced it back to the login.asp (it goes then to login2.asp to do database stuff) and i didnt put the URLEncode there as well.

    thanks for your help though

    cheerio


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •