HttpRequest.UrlReferrer 属性
定义
获取有关客户端上次请求的 URL 的信息,该请求链接到当前的 URL。Gets information about the URL of the client's previous request that linked to the current URL.
public:
property Uri ^ UrlReferrer { Uri ^ get(); };
public Uri UrlReferrer { get; }
member this.UrlReferrer : Uri
Public ReadOnly Property UrlReferrer As Uri
属性值
例外
HTTP Referer 请求标头格式不正确,并且不能转换为 Uri 对象。The HTTP Referer request header is malformed and cannot be converted to a Uri object.
示例
下面的代码示例显示了引用当前应用程序的客户端的 URL 的两个属性的值。The following code example displays the value of two properties of the URL that referred the client to the current application.
Uri MyUrl = Request.UrlReferrer;
Response.Write("Referrer URL Port: " + Server.HtmlEncode(MyUrl.Port.ToString()) + "<br>");
Response.Write("Referrer URL Protocol: " + Server.HtmlEncode(MyUrl.Scheme) + "<br>");
Dim MyUrl As Uri = Request.UrlReferrer
Response.Write("Referrer URL Port: " & Server.HtmlEncode(MyUrl.Port.ToString()) & "<br>")
Response.Write("Referrer URL Protocol: " & Server.HtmlEncode(MyUrl.Scheme) & "<br>")