title: How can I get Url Referrer in ASP.NET Core MVC?
body: <p>I am trying to migrate an ASP.NET MVC webform to ASP.NET Core MVC. Currently, I am having trouble with the <code>Request.UrlReferrer</code> class.</p>
  
  <p>The original line is:</p>
  
  <pre><code>    [HttpPost]
      public async Task&lt;ActionResult&gt; ContactUsFormSubmit(ContactUs request)
      {
          var siteUrl = Request.UrlReferrer.ToString().ToLower();
          ....
      }
  </code></pre>
  
  <p>However, with ASP.NET Core, UrlReferrer is not available. I have found the following:</p>
  
  <pre><code>    Request.Headers["Referer"]
  </code></pre>
  
  <p>which returns StringValues instead of a String. I am not sure if I should try to use this one or if there is any other solutions to this situation. <code>Request.ServerVariables</code> is also not available or maybe I don't have the namespace. My namespaces are as follows:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Mvc;
  using Newtonsoft.Json;
  using Newtonsoft.Json.Linq;
  </code></pre>
  
  <p>I would really appreciate if someone can direct me in the right direction.</p>