是否有UrlReferrer和HTTP_REFERRER的替代方案 [英] Is there any alternative for UrlReferrer and HTTP_REFERRER

查看:94
本文介绍了是否有UrlReferrer和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 the Request.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) using Response.Redirect, you will find the Request.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 a QueryString parameter (Say, http://www.mysite.com/login.aspx?FromUrl=http://abc.com/travel.aspx, Making sure you encode the FromUrl value). This QueryString 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屋!

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