在Global.asa中使用HTTP_REFERER [英] Use of HTTP_REFERER in Global.asa

查看:71
本文介绍了在Global.asa中使用HTTP_REFERER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我有以下要求。


当我的网站被任何链接打开时:说从谷歌点击

搜索结果或其他网站的链接:


然后我应该知道引荐来源网址。我怎么做到这一点?


我知道Request.ServerVariables(" HTTP_REFERER")。所以我在

" global.asa"中使用了它。文件在Session_OnStart中这样的事件:


Sub Session_OnStart

会话(" ReferralURL")= Request.ServerVariables(" HTTP_REFERER")

结束分


Sub Session_OnEnd

会话(" ReferralURL")=""

End Sub

因此我可以在我网站的任何地方使用会话变量,因为

HTTP_REFERER将给出最后一个网页的URL。

但这似乎不起作用。


请帮忙。


谢谢

Prabhat

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.ServerVariables("HTTP_REFERER"). So I used this in
"global.asa" file in "Session_OnStart" event like this:

Sub Session_OnStart
Session("ReferralURL") = Request.ServerVariables("HTTP_REFERER")
End Sub

Sub Session_OnEnd
Session("ReferralURL") = ""
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

推荐答案

Prabhat于2005年4月1日在microsoft.public.inetserver.asp.general上写道:
Prabhat wrote on 01 sep 2005 in microsoft.public.inetserver.asp.general:
你好,

我有以下要求。

什么时候通过任何链接打开我的网站:说从谷歌搜索结果点击或从其他网站链接:

然后我应该知道引荐来源网址。我如何得到它?

我知道Request.ServerVariables(HTTP_REFERER)。所以我在global.asa中使用了这个
。文件在Session_OnStart中这样的事件:

Sub Session_OnStart
Session(" ReferralURL")= Request.ServerVariables(" HTTP_REFERER")
End Sub


在这里设置一个会话变量是行不通的,恕我直言。

Sub Session_OnEnd
会话(" ReferralURL")=""
End Sub


清除会话变量在这里没有任何效果,因为所有会话

变量无论如何都会在会话结束时死亡。

所以我可以在我的网站的任何地方使用会话变量,
因为HTTP_REFERER会给出最后一个网页的URL。
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.ServerVariables("HTTP_REFERER"). So I used this
in "global.asa" file in "Session_OnStart" event like this:

Sub Session_OnStart
Session("ReferralURL") = Request.ServerVariables("HTTP_REFERER")
End Sub
Seting a session variable here will not work, IMHO.
Sub Session_OnEnd
Session("ReferralURL") = ""
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.




不,在你的情况下它会[但是在打开会话时不会只提供推荐的网址

网站。


最好把这个文件作为一个包含

<! - #include virtual =" /test/myInclude.asp" - >
所有页面上的



/test/myInclude.asp:

<%

if Session(&quo) t; started")=""然后

会话(" ReferralURL")= Request.ServerVariables(" HTTP_REFERER")

会话(" started")=" yes!"

结束如果

%>

-

Evertjan。

荷兰。

(用我的电子邮件地址替换所有带点的十字架)



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("started") = "" then
Session("ReferralURL") = Request.ServerVariables("HTTP_REFERER")
Session("started") = "yes!"
end if
%>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


您好Evertjan,感谢您的回复。


你的意思是说如果我在Session_OnStart中放置Session(ReferralURL)=

Request.ServerVariables(" HTTP_REFERER")它将无效。

我也测试了它,但它无法正常工作。你能解释一下原因吗?

因为据我所知,Session_OnStart活动将从每个

会话开始。


按照你的建议我将使用示例代码创建一个.asp文件,并且

包含所有页面中的文件。


你能建议一个简单的方法让我不需要修改所有页面

包含新文件?


我认为你的逻辑说如果会话变量开始了是空的然后

只用转发URL分配会话变量否则没有。


但是你不认为我也应该在Session_OnEnd上创建这些变量
活动?请建议。


谢谢

Prabhat

Evertjan。 <前************** @ interxnl.net>在留言中写道

news:Xn ******************** @ 194.109.133.242 ...
Hi Evertjan, Thanks for reply.

You mean to say if I put the Session("ReferralURL") =
Request.ServerVariables("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********************@194.109.133.242...
Prabhat 2005年4月1日在microsoft.public.inetserver.asp.general写道:
Prabhat wrote on 01 sep 2005 in microsoft.public.inetserver.asp.general:
你好,

我有以下要求。

然后我应该知道引荐来源网址。我如何得到它?

我知道Request.ServerVariables(HTTP_REFERER)。所以我在global.asa中使用了这个
。文件在Session_OnStart中这样的事件:

Sub Session_OnStart
会话(" ReferralURL")= Request.ServerVariables(" HTTP_REFERER")
End Sub
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.ServerVariables("HTTP_REFERER"). So I used this
in "global.asa" file in "Session_OnStart" event like this:

Sub Session_OnStart
Session("ReferralURL") = Request.ServerVariables("HTTP_REFERER")
End Sub



在这里设置一个会话变量是行不通的,恕我直言。



Seting a session variable here will not work, IMHO.

Sub Session_OnEnd
Session(" ReferralURL")=""
End Sub
Sub Session_OnEnd
Session("ReferralURL") = ""
End Sub



在这里清除会话变量没有任何效果,因为无论如何所有会话
变量都会在会话结束时死亡。



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

因此我可以在我的网站中的任何位置使用会话变量,因为HTTP_REFERER将提供最后一个网页的URL。
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.



不,在你的情况下它会[但是在打开会话时不会只提供推荐链接的网址。

最好把这个文件作为一个包含
<! - #include virtual = /test/myInclude.asp" - >
在您的所有网页上:

/test/myInclude.asp:
<%然后
会话(" ReferralURL")= Request.ServerVariables(" HTTP_REFERER")
会话(" started")=" yes!"
结束如果
%>

-
Evertjan。
荷兰。
(用我的电子邮件中的点替换所有十字架)



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("started") = "" then
Session("ReferralURL") = Request.ServerVariables("HTTP_REFERER")
Session("started") = "yes!"
end if
%>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)



Prabhat于2005年4月1日在microsoft.public.inetserver.asp.general中写道:
Prabhat wrote on 01 sep 2005 in microsoft.public.inetserver.asp.general:
" Evertjan。 <前************** @ interxnl.net>在消息中写道
"Evertjan." <ex**************@interxnl.net> wrote in message
Prabhat于2005年4月1日在
Prabhat wrote on 01 sep 2005 in
>中写道我知道Request.ServerVariables(HTTP_REFERER)。所以我用了
>这在global.asa中文件在Session_OnStart中这样的事件:
>
> Sub Session_OnStart
>会话(" ReferralURL")= Request.ServerVariables(" HTTP_REFERER")
> End Sub
在这里设置一个会话变量是行不通的,恕我直言。
> I know about Request.ServerVariables("HTTP_REFERER"). So I used
> this in "global.asa" file in "Session_OnStart" event like this:
>
> Sub Session_OnStart
> Session("ReferralURL") = Request.ServerVariables("HTTP_REFERER")
> End Sub
Seting a session variable here will not work, IMHO.
> Sub Session_OnEnd
>会话(ReferralURL)=""
> End Sub
> Sub Session_OnEnd
> Session("ReferralURL") = ""
> End Sub



在此处清除会话变量无效,因为无论如何所有会话
变量都会在会话结束时死亡。



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

>这样我就可以在我网站的任何地方使用会话变量,
>因为HTTP_REFERER会给出最后一个网页的URL。
> 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.



不,在你的情况下,它会[但不会]仅提供推荐的网址
打开会议。

最好把这个文件作为一个包含
<! - #include virtual =" /test/myInclude.asp" - >
on您的所有页面:

/test/myInclude.asp:
<%
如果会话(已开始)=""然后
会话(" ReferralURL")= Request.ServerVariables(" HTTP_REFERER")
会话(" started")=" yes!"
结束如果
%>



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("started") = "" then
Session("ReferralURL") = Request.ServerVariables("HTTP_REFERER")
Session("started") = "yes!"
end if
%>




[请不要在usenet上使用]

你的意思是说我是否把会话(& ; ReferralURL")=
Session_OnStart中的Request.ServerVariables(" HTTP_REFERER")它将无法正常工作。我也测试了它,它不起作用。你能解释一下原因吗?因为根据我的知识,Session_OnStart事件将为每个会话启动。


符合规格。只有certein对象可用

在global.asa中,我认为

根据你的建议,我将创建一个包含示例代码的.asp文件并包含所有页面都有文件。

你能建议一个简单的方法,这样我就不需要修改所有的页面来包含新文件吗?


编号除非你的意思是用C ++或VB等进行本地编程..

我认为你的逻辑说如果会话变量开始的话。是空的然后只分配会话变量和引用URL否则
没有。


否则会话(ReferralURL)将填写每个参考

本地页面。

但你不觉得我还应该在Session_OnEnd事件上发现这些变量吗?请建议。



[please do not toppost on usenet]
You mean to say if I put the Session("ReferralURL") =
Request.ServerVariables("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("ReferralURL") would be filled with each referring
local page.
But dont you think I should also crear these variables on
Session_OnEnd event? Please suggest.




正如我所说,不。


1自动删除没有会话的会话变量。


2 Session_OnEnd射击是不可靠的。


3当用户离开时,会话不会结束。 [草率定义]网站,

但仅限于会话超时或使用session.abandon

或服务器关闭/重启等命令时。

-

Evertjan。

荷兰。

(用我的电子邮件地址替换所有带点的十字架)



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)


这篇关于在Global.asa中使用HTTP_REFERER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆