是否有UrlReferrer和HTTP_REFERRER的替代方案 [英] Is there any alternative for UrlReferrer and HTTP_REFERRER
问题描述
使用Urlreferrer和HTTP_REFERRER有很多限制。那么,两者都有其他选择。
实际上我遇到的问题是两者在我的本地机器上工作正常但没有在实时环境中给出结果。 br />
以上是否有其他选择。
以下是场景:
有一个站点说http://mysite.com/login.aspx - 它在Page_Load捕获传入的URL
用户来自其他网站,例如:
http://abc.com/travel.aspx
http://bnc.org /getinto.aspx
任何建议/解决方案都会非常明显。
There are many restriction in the use of both Urlreferrer and HTTP_REFERRER. So, is there any alternative for the both.
Actually I am facing the problem the both are working fine on my local machine but not giving result on live environment.
Is there any alternative to the above.
Here is the scenarios:
There is a site say http://mysite.com/login.aspx - it captures the incoming urls at Page_Load
user is coming from other sites like;
http://abc.com/travel.aspx
http://bnc.org/getinto.aspx
Any suggestion/solution will be most appreciable.
推荐答案
你会发现价值仅当通过单击当前Asp.net Web应用程序上的链接启动当前请求时,才在Request.UrlReferrer
中。否则,如果使用Response.Redirect
将请求重定向到页面(来自当前网站或其他网站),您将找到Request.UrlReferrer
value为null。
作为解决方法,当您重定向到目标页面时(在当前站点内)或者从其他网站),你可以追加一个QueryString
参数(比如说,http://www.mysite.com/login.aspx?FromUrl = http://abc.com/travel.aspx
,确保编码FromUrl
值。此QueryString
参数值将包含发起当前请求的URL。
我使用此技术我的一个项目。希望,这对你有帮助。
You will find value in theRequest.UrlReferrer
only if the current request is initiated by clicking on a Link at the current Asp.net web application. Otherwise, if the request is redirected to a page (Be it from the current web site or a different web site) usingResponse.Redirect
, you will find theRequest.UrlReferrer
value to be null.
As a workaround, when you redirect to your target page (From within the current site or from the other sites), you can append aQueryString
parameter (Say,http://www.mysite.com/login.aspx?FromUrl=http://abc.com/travel.aspx
, Making sure you encode theFromUrl
value). ThisQueryString
parameter value will contain the URL from where the current request is originated.
I used this technique in one of my project. Hope, this will help you.
这篇关于是否有UrlReferrer和HTTP_REFERRER的替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!