0

I am working on a web application, I came to a situation that I need to know from which website the user came to my website. What I am looking for is:

<a target="_blank" href="http://localhost:18835/index.aspx">To Web application</a>

is on one website say StackOverflow and on that index.aspx page load I need to know that the request is coming from StackOverflow or any other website I need to know the URL where the page request is made.

How can I do that?

string referencepage = HttpContext.Current.Request.UrlReferrer.AbsoluteUri;
label1.Text = "You Came from:-" + referencepage;

this code will work when the request is made within the current URL, so what if the request is coming from outside ???

Aju
  • 503
  • 1
  • 8
  • 26
  • Does this answer your question? [Getting the HTTP Referrer in ASP.NET](https://stackoverflow.com/questions/4258217/getting-the-http-referrer-in-asp-net) – Nax.S Dec 21 '20 at 08:18

1 Answers1

0
if (Request.ServerVariables["HTTP_REFERER"] != null)
{
    Response.Write(Request.ServerVariables["HTTP_REFERER"].ToString());
}
MrinmoyeeG
  • 106
  • 5