【发布时间】:2020-12-21 08:08:53
【问题描述】:
我正在开发一个 Web 应用程序,我遇到了一种情况,我需要知道用户是从哪个网站访问我的网站的。 我要找的是:
<a target="_blank" href="http://localhost:18835/index.aspx">To Web application</a>
在一个网站上说 StackOverflow 并且在该 index.aspx 页面加载时,我需要知道请求来自 StackOverflow 或任何其他网站,我需要知道发出页面请求的 URL。
我该怎么做?
string referencepage = HttpContext.Current.Request.UrlReferrer.AbsoluteUri;
label1.Text = "You Came from:-" + referencepage;
当请求是在当前 URL 内发出时,此代码将起作用,那么如果请求来自外部怎么办???
【问题讨论】:
-
这能回答你的问题吗? Getting the HTTP Referrer in ASP.NET
标签: c# asp.net asp.net-core