...

View Full Version : script name full with querystring?



reubenb
09-28-2005, 12:59 PM
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

glenngv
09-28-2005, 01:26 PM
str = Request.ServerVariables("SCRIPT_NAME") & "?" & Request.QueryString
Response.Write str

or


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.


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

reubenb
09-30-2005, 06:59 AM
if i response.redirect them [using the first one] of the str, it doesn't work.

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

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

glenngv
09-30-2005, 09:23 AM
Is there any error? Is the value of str correct? How about the other one?

reubenb
09-30-2005, 09:27 AM
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.

glenngv
09-30-2005, 10:08 AM
Can you post the code and actual url to be redirect?

reubenb
09-30-2005, 10:21 AM
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


if request("referer") = "" then
Response.Redirect "default.asp"
else Response.Redirect(request("referer"))
end if

glenngv
09-30-2005, 10:44 AM
You should encode the URL to be redirected so that the querystring will be passed to the other page properly.

pagerefer = "login.asp?lg=nologin&referer="
pagerefer = pagerefer & Server.URLEncode(pagename)
response.redirect(pagerefer)

reubenb
10-02-2005, 09:17 AM
Cheers mate :)

reubenb
10-02-2005, 09:21 AM
still doesn't worK?

glenngv
10-03-2005, 06:33 AM
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.


request.querystring("referer")

Although QueryString is the first, it is a good habit to not rely on the default properties or methods of objects.

reubenb
10-03-2005, 07:27 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum