Forums

ASP

This topic is locked

http_referer nightmare

Posted 21 Oct 2003 13:30:51
1
has voted
21 Oct 2003 13:30:51 Dave Desormeaux posted:
I want to use HTTP_REFERER variable but only want to return information up to and including the script name. Example:

If the referring URL is www.something.com/news.asp?todaysnews

I only want to get: www.something.com/news.asp


Then I want to do an if/then statement that says

IF the referring page is different than the current page that is being viewed, then perform this action:

EG: IF varReferringPage = varCurrentPage then

response.write "one thing"

else

response.write "another thing"


The reason for doing this is because I am using ASP for a photo web site. I have a random image that appears at the top of each asp page. But I don't want the image to change if the user is staying on the same dynamic page.

I hope this makes sense.


I've tried this script which works if I'm just writing to the page:

<pre id=code><font face=courier size=2 id=code> &lt;
% Sub StrRefurl
Dim strURL, arrURL, x
'Uncomment to use referring page
strURL = Request.ServerVariables("HTTP_REFERRER"
'Simulated example
strURL = ( "" & Request.ServerVariables("SERVER_NAME" & Request.ServerVariables("URL" )
'Split example into array based on / char
arrURL = Split(strURL, "/"
' Loop through array and show URL parts
Response.Write ""
For x = 2 to UBound(arrURL)
If trim(arrURL(x)) &gt; "" Then
Response.Write arrURL(x) & "/"
End If
Next
End sub %&gt;


&lt;% Sub CurrentUrl
Dim StrUrl_3
StrUrl_3 = ( "" & Request.ServerVariables("SERVER_NAME" & Request.ServerVariables("URL" & "/" )
Response.write StrUrl_3
End Sub %&gt;

</font id=code></pre id=code>



But when I try to use the data in an if/then statement, the data does not seem to be getting there properly:

IF "CurrentUrl" = "StrRefurl" then
Response.write "this is the same REFRESHED page"
else
Response.write "you have reached this from a very different page"
END if
%&gt;

Any help would be truly appreciated.


dave

Reply to this topic