473,564 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use of HTTP_REFERER in Global.asa

Hello,

I have the below requirement.

When ever my website is opened by any link: say clicked from the google
search result or a link from other website:

Then I should able to know the referrer URL. How Do I get that?

I know about Request.ServerV ariables("HTTP_ REFERER"). So I used this in
"global.asa " file in "Session_OnStar t" event like this:

Sub Session_OnStart
Session("Referr alURL") = Request.ServerV ariables("HTTP_ REFERER")
End Sub

Sub Session_OnEnd
Session("Referr alURL") = ""
End Sub

So that I can use the session variable any where in my website, because the
HTTP_REFERER will give the URL of the last webpage.

But this seems to not working.

Please help.

Thanks
Prabhat
Sep 1 '05 #1
28 4860
Prabhat wrote on 01 sep 2005 in microsoft.publi c.inetserver.as p.general:
Hello,

I have the below requirement.

When ever my website is opened by any link: say clicked from the
google search result or a link from other website:

Then I should able to know the referrer URL. How Do I get that?

I know about Request.ServerV ariables("HTTP_ REFERER"). So I used this
in "global.asa " file in "Session_OnStar t" event like this:

Sub Session_OnStart
Session("Referr alURL") = Request.ServerV ariables("HTTP_ REFERER")
End Sub
Seting a session variable here will not work, IMHO.
Sub Session_OnEnd
Session("Referr alURL") = ""
End Sub
Clearing a session variable here has no effect, since all session
variables die with the end of a session anyway.
So that I can use the session variable any where in my website,
because the HTTP_REFERER will give the URL of the last webpage.


No, in your case it would [but doesn't] give only the URL of referral
site when opening the session.

Better put this file as an include
<!--#include virtual ="/test/myInclude.asp"-->
on all your pages:

/test/myInclude.asp:
<%
if Session("starte d") = "" then
Session("Referr alURL") = Request.ServerV ariables("HTTP_ REFERER")
Session("starte d") = "yes!"
end if
%>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Sep 1 '05 #2
Hi Evertjan, Thanks for reply.

You mean to say if I put the Session("Referr alURL") =
Request.ServerV ariables("HTTP_ REFERER") in Session_OnStart it will not work.
I have also tested that and it is not working. Can you please explain why?
Because as per my knowledge the Session_OnStart event will start for each
session.

As per your suggestion I will create one .asp file with the sample code and
include the file in all pages.

Can you suggest an easy method so that I need not to modify all the pages to
include the new file?

I think your logic says that if the Session Variable "started" is empty then
only assign the Session Variable with the Referral URL else no.

But dont you think I should also crear these variables on Session_OnEnd
event? Please suggest.

Thanks
Prabhat
"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ************@19 4.109.133.242.. .
Prabhat wrote on 01 sep 2005 in microsoft.publi c.inetserver.as p.general:
Hello,

I have the below requirement.

When ever my website is opened by any link: say clicked from the
google search result or a link from other website:

Then I should able to know the referrer URL. How Do I get that?

I know about Request.ServerV ariables("HTTP_ REFERER"). So I used this
in "global.asa " file in "Session_OnStar t" event like this:

Sub Session_OnStart
Session("Referr alURL") = Request.ServerV ariables("HTTP_ REFERER")
End Sub


Seting a session variable here will not work, IMHO.
Sub Session_OnEnd
Session("Referr alURL") = ""
End Sub


Clearing a session variable here has no effect, since all session
variables die with the end of a session anyway.
So that I can use the session variable any where in my website,
because the HTTP_REFERER will give the URL of the last webpage.


No, in your case it would [but doesn't] give only the URL of referral
site when opening the session.

Better put this file as an include
<!--#include virtual ="/test/myInclude.asp"-->
on all your pages:

/test/myInclude.asp:
<%
if Session("starte d") = "" then
Session("Referr alURL") = Request.ServerV ariables("HTTP_ REFERER")
Session("starte d") = "yes!"
end if
%>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Sep 1 '05 #3
Prabhat wrote on 01 sep 2005 in microsoft.publi c.inetserver.as p.general:
"Evertjan." <ex************ **@interxnl.net > wrote in message
Prabhat wrote on 01 sep 2005 in
> I know about Request.ServerV ariables("HTTP_ REFERER"). So I used
> this in "global.asa " file in "Session_OnStar t" event like this:
>
> Sub Session_OnStart
> Session("Referr alURL") = Request.ServerV ariables("HTTP_ REFERER")
> End Sub
Seting a session variable here will not work, IMHO.
> Sub Session_OnEnd
> Session("Referr alURL") = ""
> End Sub


Clearing a session variable here has no effect, since all session
variables die with the end of a session anyway.
> So that I can use the session variable any where in my website,
> because the HTTP_REFERER will give the URL of the last webpage.


No, in your case it would [but doesn't] give only the URL of referral
site when opening the session.

Better put this file as an include
<!--#include virtual ="/test/myInclude.asp"-->
on all your pages:

/test/myInclude.asp:
<%
if Session("starte d") = "" then
Session("Referr alURL") = Request.ServerV ariables("HTTP_ REFERER")
Session("starte d") = "yes!"
end if
%>


[please do not toppost on usenet]
You mean to say if I put the Session("Referr alURL") =
Request.ServerV ariables("HTTP_ REFERER") in Session_OnStart it will not
work. I have also tested that and it is not working. Can you please
explain why? Because as per my knowledge the Session_OnStart event
will start for each session.
It is als per specification. Only certein objects are available
in global.asa, I think
As per your suggestion I will create one .asp file with the sample
code and include the file in all pages.

Can you suggest an easy method so that I need not to modify all the
pages to include the new file?
No. Unless you mean local programming in C++ or VB etc..
I think your logic says that if the Session Variable "started" is
empty then only assign the Session Variable with the Referral URL else
no.
Otherwise Session("Referr alURL") would be filled with each referring
local page.
But dont you think I should also crear these variables on
Session_OnEnd event? Please suggest.


As I said, no.

1 Session variables without sessions are deleted automaticly.

2 Session_OnEnd firing is unrelyable.

3 Sessions do not end, when the user "leaves" [sloppy defined] the site,
but only when the session times out or with commands like session.abandon
or with the server closing down/restarting.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Sep 1 '05 #4

"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ************@19 4.109.133.242.. .
Prabhat wrote on 01 sep 2005 in microsoft.publi c.inetserver.as p.general:
"Evertjan." <ex************ **@interxnl.net > wrote in message
Prabhat wrote on 01 sep 2005 in
> I know about Request.ServerV ariables("HTTP_ REFERER"). So I used
> this in "global.asa " file in "Session_OnStar t" event like this:
>
> Sub Session_OnStart
> Session("Referr alURL") = Request.ServerV ariables("HTTP_ REFERER")
> End Sub

Seting a session variable here will not work, IMHO.

> Sub Session_OnEnd
> Session("Referr alURL") = ""
> End Sub

Clearing a session variable here has no effect, since all session
variables die with the end of a session anyway.

> So that I can use the session variable any where in my website,
> because the HTTP_REFERER will give the URL of the last webpage.

No, in your case it would [but doesn't] give only the URL of referral
site when opening the session.

Better put this file as an include
<!--#include virtual ="/test/myInclude.asp"-->
on all your pages:

/test/myInclude.asp:
<%
if Session("starte d") = "" then
Session("Referr alURL") = Request.ServerV ariables("HTTP_ REFERER")
Session("starte d") = "yes!"
end if
%>


[please do not toppost on usenet]
You mean to say if I put the Session("Referr alURL") =
Request.ServerV ariables("HTTP_ REFERER") in Session_OnStart it will not
work. I have also tested that and it is not working. Can you please
explain why? Because as per my knowledge the Session_OnStart event
will start for each session.


It is als per specification. Only certein objects are available
in global.asa, I think
As per your suggestion I will create one .asp file with the sample
code and include the file in all pages.

Can you suggest an easy method so that I need not to modify all the
pages to include the new file?


No. Unless you mean local programming in C++ or VB etc..
I think your logic says that if the Session Variable "started" is
empty then only assign the Session Variable with the Referral URL else
no.


Otherwise Session("Referr alURL") would be filled with each referring
local page.
But dont you think I should also crear these variables on
Session_OnEnd event? Please suggest.


As I said, no.

1 Session variables without sessions are deleted automaticly.

2 Session_OnEnd firing is unrelyable.

3 Sessions do not end, when the user "leaves" [sloppy defined] the site,
but only when the session times out or with commands like session.abandon
or with the server closing down/restarting.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


Hi Evertjan,

Thanks for the reply. Now I understodd the concept. Thanks for the post.

Prabaht
Sep 1 '05 #5
Does anybody see what's wrong with bottom-posting here? Just curious if
it's only me that is irritated to scroll through 90 lines of re-hashed
garbage to see "thank you."

"Prabhat" <no********@hot mail.com> wrote in message
news:Om******** ******@TK2MSFTN GP12.phx.gbl...

"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ************@19 4.109.133.242.. .
Prabhat wrote on 01 sep 2005 in microsoft.publi c.inetserver.as p.general:
> "Evertjan." <ex************ **@interxnl.net > wrote in message
>> Prabhat wrote on 01 sep 2005 in
.... >> > this in "global.asa " file in "Session_OnStar t" event like this:
>> >
>> > Sub Session_OnStart
>> > Session("Referr alURL") = Request.ServerV ariables("HTTP_ REFERER")
>> > End Sub
>>
>> Seting a session variable here will not work, IMHO.
>>
>> > Sub Session_OnEnd
>> > Session("Referr alURL") = ""
>> > End Sub
>>
>> Clearing a session variable here has no effect, since all session
>> variables die with the end of a session anyway.
>>
>> > So that I can use the session variable any where in my website,
>> > because the HTTP_REFERER will give the URL of the last webpage.
>>
>> No, in your case it would [but doesn't] give only the URL of referral
>> site when opening the session.
>>
>> Better put this file as an include
>> <!--#include virtual ="/test/myInclude.asp"-->
>> on all your pages:
>>
>> /test/myInclude.asp:
>> <%
>> if Session("starte d") = "" then
>> Session("Referr alURL") = Request.ServerV ariables("HTTP_ REFERER")
>> Session("starte d") = "yes!"
>> end if
>> %>


[please do not toppost on usenet]
> You mean to say if I put the Session("Referr alURL") =
> Request.ServerV ariables("HTTP_ REFERER") in Session_OnStart it will not
> work. I have also tested that and it is not working. Can you please
> explain why? Because as per my knowledge the Session_OnStart event
> will start for each session.


It is als per specification. Only certein objects are available
in global.asa, I think
> As per your suggestion I will create one .asp file with the sample
> code and include the file in all pages.
>
> Can you suggest an easy method so that I need not to modify all the
> pages to include the new file?


No. Unless you mean local programming in C++ or VB etc..
> I think your logic says that if the Session Variable "started" is
> empty then only assign the Session Variable with the Referral URL else
> no.


Otherwise Session("Referr alURL") would be filled with each referring
local page.
> But dont you think I should also crear these variables on
> Session_OnEnd event? Please suggest.


As I said, no.

1 Session variables without sessions are deleted automaticly.

2 Session_OnEnd firing is unrelyable.

3 Sessions do not end, when the user "leaves" [sloppy defined] the site,
but only when the session times out or with commands like session.abandon
or with the server closing down/restarting.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


Hi Evertjan,

Thanks for the reply. Now I understodd the concept. Thanks for the post.

Prabaht

Sep 1 '05 #6
Evertjan. wrote:
You mean to say if I put the Session("Referr alURL") =
Request.ServerV ariables("HTTP_ REFERER") in Session_OnStart it will
not work. I have also tested that and it is not working. Can you
please explain why? Because as per my knowledge the Session_OnStart
event will start for each session.


It is als per specification. Only certein objects are available
in global.asa, I think


This would appear to contradict that claim:

"All the built-in objects (Application Object, ObjectContext
Object, Request Object, Response Object, Server Object, and
Session Object) are available and can be referenced in the
Session_OnStart event script."

http://msdn.microsoft.com/library/en...f289198c16.asp

--
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.
Sep 1 '05 #7
Aaron Bertrand [SQL Server MVP] wrote on 01 sep 2005 in
microsoft.publi c.inetserver.as p.general:
Does anybody see what's wrong with bottom-posting here? Just curious if
it's only me that is irritated to scroll through 90 lines of re-hashed
garbage to see "thank you."


Bottom-posting is not the alternative of top-posting, Aaron.
Re-posting garbage is always a bad habit.
Sparse inter-posting is the best.
Top-posting should be discouraged at all times on usenet.

I am sorry that you ar so easily irritated,
and thereby forgetting what 30 years of
usenet experience brought us:
Netiquette.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Sep 1 '05 #8
Nah, it's lack of snipping, not where the reply was put.

Aaron Bertrand [SQL Server MVP] wrote:
Does anybody see what's wrong with bottom-posting here? Just curious
if it's only me that is irritated to scroll through 90 lines of
re-hashed garbage to see "thank you."


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Sep 1 '05 #9
"Aaron Bertrand [SQL Server MVP]" <te*****@dnartr eb.noraa> wrote in message
news:ut******** ******@TK2MSFTN GP09.phx.gbl...
"Prabhat" <no********@hot mail.com> wrote in message
news:Om******** ******@TK2MSFTN GP12.phx.gbl...

"Evertjan." <ex************ **@interxnl.net > wrote in message
news:Xn******** ************@19 4.109.133.242.. .
Prabhat wrote on 01 sep 2005 in microsoft.publi c.inetserver.as p.general:
> "Evertjan." <ex************ **@interxnl.net > wrote in message
>> Prabhat wrote on 01 sep 2005 in
... >> > this in "global.asa " file in "Session_OnStar t" event like this:
>> >
>> > Sub Session_OnStart
>> > Session("Referr alURL") = Request.ServerV ariables("HTTP_ REFERER")
>> > End Sub
>>
>> Seting a session variable here will not work, IMHO.
>>
>> > Sub Session_OnEnd
>> > Session("Referr alURL") = ""
>> > End Sub
>>
>> Clearing a session variable here has no effect, since all session
>> variables die with the end of a session anyway.
>>
>> > So that I can use the session variable any where in my website,
>> > because the HTTP_REFERER will give the URL of the last webpage.
>>
>> No, in your case it would [but doesn't] give only the URL of referral
>> site when opening the session.
>>
>> Better put this file as an include
>> <!--#include virtual ="/test/myInclude.asp"-->
>> on all your pages:
>>
>> /test/myInclude.asp:
>> <%
>> if Session("starte d") = "" then
>> Session("Referr alURL") = Request.ServerV ariables("HTTP_ REFERER")
>> Session("starte d") = "yes!"
>> end if
>> %>

[please do not toppost on usenet]

> You mean to say if I put the Session("Referr alURL") =
> Request.ServerV ariables("HTTP_ REFERER") in Session_OnStart it will not
> work. I have also tested that and it is not working. Can you please
> explain why? Because as per my knowledge the Session_OnStart event
> will start for each session.

It is als per specification. Only certein objects are available
in global.asa, I think

> As per your suggestion I will create one .asp file with the sample
> code and include the file in all pages.
>
> Can you suggest an easy method so that I need not to modify all the
> pages to include the new file?

No. Unless you mean local programming in C++ or VB etc..

> I think your logic says that if the Session Variable "started" is
> empty then only assign the Session Variable with the Referral URL else
> no.

Otherwise Session("Referr alURL") would be filled with each referring
local page.

> But dont you think I should also crear these variables on
> Session_OnEnd event? Please suggest.

As I said, no.

1 Session variables without sessions are deleted automaticly.

2 Session_OnEnd firing is unrelyable.

3 Sessions do not end, when the user "leaves" [sloppy defined] the site,
but only when the session times out or with commands like
session.abandon
or with the server closing down/restarting.


Hi Evertjan,

Thanks for the reply. Now I understodd the concept. Thanks for the post.


[repositioned from top-posted reply]
Does anybody see what's wrong with bottom-posting here? Just curious if
it's only me that is irritated to scroll through 90 lines of re-hashed
garbage to see "thank you."


Nowhere near as irritating as someone who breaks the flow of a thread.
Sep 1 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9544
by: John A. Irwin | last post by:
I'm very new to PHP and am trying to figure out how to parse out a variable "HTTP_REFERER". My reason for this is my site was recently "FEATURED" (sic) on a website called FARK.COM. Because of this I received over 100,000 Hits in less then one hour and it caused my host's server farm to crash. While I understand that I could move to a more...
9
30887
by: Jez | last post by:
Any ideas why I'm not able to use $_SERVER on my shared hosting account (PHP 4.1.2), but I can on my local server (PHP 4.3.3)? I imagine it has something to do with the different versions of PHP or perhaps php.ini, but I'm not sure what? Thanks! Jez
9
28661
by: deko | last post by:
I have a page that I don't want anyone to be able to link directly to. The page should only be accessed from gatepage.php. I tried this code, but keep getting errors - "header info already sent", or something like that... Am I missing something, or is there a better way to do this? <?php $ref = $_SERVER; //echo $ref; if ( $ref ==...
2
5629
by: ssk | last post by:
Hello! I made a web site using PHP Open sources for message board. Everything's fine except one computer can't open a message writing page. The code that gives an error is the following. if(!eregi($HTTP_HOST,$HTTP_REFERER)) Error("Write in the normal way");
2
1657
by: M Smith | last post by:
On our web site we allow our members access to features hosted by another web site. The way the other web site authenticates users is to check the value of the HTTP_REFERER. If it comes from our Login.asp page it lets them in. When our users login to go to the other site, they login on our site's Login.asp page. When they click submit, our...
4
5277
by: Ringo Langly | last post by:
Hi everyone, We're using an outside vendor to provide some content for our website, and they use the http_referer variable to verify their content is only viewed from subscribing customers. Anyway, we're using the mm_menu javascript menu for our web menus, and under only Internet Explorer it's not passing the http_referer -- which means...
8
1850
by: tshad | last post by:
Why would HTTP_REFERER not be there in the Page_Load event? I am using it to determine whether a page was called from a particular page. I am doing: sTest = Request.ServerVariables("HTTP_REFERER") if (sTest = "") ORELSE (sTest.SubString(sTest.LastIndexOf("/")+1) <> "job_posting_new2.aspx") then newPosition = new Position
16
3772
by: Seguros Catatumbo | last post by:
Hi everyone. Is there a way i can find out the value of HTTP_REFERER when using application_error in global.asax? I am using: if (HttpContext.Current.Request.ServerVariables != null) { referencia = HttpContext.Current.Request.ServerVariables.ToString();
6
5342
by: Lorna | last post by:
I can't seem to get the ENV variable HTTP_REFERER when posting with CGI from one program to another. In my post program I have put in the <HEAD> HTTP_REFERER =my host - ie www.xyz.com (I have also tried removing it entirely in case that was causing problems. I have tried to extract the HTTP_REFERER in my receiving program with $http_ref...
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.