C#获取HTTP请求的Referer的示例:
/// <summary> /// 获取HTTP请求的Referer /// </summary> /// <param name="ishost">Referer为空时是否返回Host(网站首页地址)</param> /// <returns>string</returns> public string GetReferer(bool ishost) { if ( Request.UrlReferrer != null) { return Request.UrlReferrer.ToString(); } else { if (ishost) { return Request.Url.Scheme + "://" + Request.Url.Authority; } else { return ""; } } }
声明:如需转载,请注明来源于www.webym.net并保留原文链接:http://www.webym.net/jiaocheng/751.html