I am trying to migrate an ASP.NET MVC webform to ASP.NET Core MVC. Currently, I am having trouble with the Request.UrlReferrer
class.
The original line is:
[HttpPost]
public async Task<ActionResult> ContactUsFormSubmit(ContactUs request)
{
var siteUrl = Request.UrlReferrer.ToString().ToLower();
....
}
However, with ASP.NET Core, UrlReferrer is not available. I have found the following:
Request.Headers["Referer"]
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. Request.ServerVariables
is also not available or maybe I don't have the namespace. My namespaces are as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
I would really appreciate if someone can direct me in the right direction.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…