HttpContext.Current.Request.UrlReferrer is always null ASP.NET MVC

Viewed 12731

UrlReferrer is always null in Firfox

What I want to do is to get the URL of coming request

So I thought to pass the URL from the Razor view to controller in response header that way

Razor View

@{ 
    string url = HttpContext.Current.Request.UrlReferrer.ToString();
    HttpContext.Current.Response.Headers.Add("CustomeUrl", url);
}

and get the hearder value like that way in the controller

Controller

public string SaveUploadedFile(HttpPostedFileBase fileBase)
{
    string url = HttpContext.Current.Request.Headers.Keys["CustomeUrl"].ToString();
}

but unfortunately the above code didn't work because HttpContext.Current.Request.Headers.Keys["CustomeUrl"].ToString(); is null

Please help me to pass the url from View to Controller

2 Answers
Related