ServerVariables("URL") return incorrect pagename

M

Martin

Hi,
From Page1.asp, I use "Server.transfer" to "REDIRECT" to another asp page
(page2.asp),
in page2.asp I use Request.ServerVariables("URL") and
Request.ServerVariables("REFERER") to get the lastpage and the actual page,
this method (or property) return incorrect values: "Page1.asp" and ""

Why?
Martin
 
A

Aaron Bertrand [SQL Server MVP]

Server.Transfer is not a redirect and does not register a referral. The
ServerVariables collection is correct. Did the URL in your browser change
to page2.asp? No. Did you loop through *all* of the servervariables?
 
D

Dave Anderson

Martin said:
From Page1.asp, I use "Server.transfer" to "REDIRECT" to another asp
page (page2.asp),
in page2.asp I use Request.ServerVariables("URL") and
Request.ServerVariables("REFERER") to get the lastpage and the
actual page, this method (or property) return incorrect values:
"Page1.asp" and ""

Why?

RTM:

Method: Server.Transfer
Description: Sends all of the current state information to another
.asp file for processing.

http://msdn.microsoft.com/library/en-us/iissdk/html/ae484208-37bf-4b6a-aada-270507db91a5.asp


Server.Transfer Method
The Transfer method sends all of the information that has been
assembled for processing by one .asp file to a second .asp file.

http://msdn.microsoft.com/library/en-us/iissdk/html/d47bdda3-96e1-46c3-b872-a038c2a61317.asp


That's why.


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
M

Mike

Simply put, Server.Transfer transfers execution to a different page on
the server. This is transparent to the URL that was requested by the
browser. Consquently, Request.ServerVariables("URL") would reflect
whatever page was requested by the browser.

Try using Request.ServerVariables("SCRIPT_NAME") or
Request.ServerVariables("PATH_INFO") to acheive the desired results.
I'm not positive that even these will work however, as the execution of
the page2 may still be viewed in the context of page1.
 

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

Forum statistics

Threads
474,149
Messages
2,570,841
Members
47,388
Latest member
EarthaGilm

Latest Threads

Top