in asp.net 4.0 url von Middleware neu zu schreiben, wir mir die Arbeit mit http-Modul neu zu schreiben Modul wie auf diese WeiseASP.Net MVC: Wie in ASP.NET Core-
protected void Application_BeginRequest(Object sender, EventArgs e)
{
string CountryCodeInUrl = "", redirectUrl="";
var countryCode = CookieSettings.ReadCookie();
if (countryCode=="")
{
countryCode = "gb";
}
if (HttpContext.Current.Request.RawUrl.Length >= 2)
{
CountryCodeInUrl = HttpContext.Current.Request.RawUrl.Substring(1, 2);
}
if (countryCode != CountryCodeInUrl)
{
if (HttpContext.Current.Request.RawUrl.Length >= 2)
{
if (HttpContext.Current.Request.RawUrl.Substring(1, 2) != "")
{
countryCode = HttpContext.Current.Request.RawUrl.Substring(1, 2);
}
}
if(!System.Web.HttpContext.Current.Request.RawUrl.Contains(countryCode))
{
redirectUrl = string.Format("/{0}{1}", countryCode, System.Web.HttpContext.Current.Request.RawUrl);
}
else
{
redirectUrl = System.Web.HttpContext.Current.Request.RawUrl;
}
CookieSettings.SaveCookie(countryCode);
System.Web.HttpContext.Current.Response.RedirectPermanent(redirectUrl);
}
}
jetzt sagen, wie kann ich verwenden können, den obigen Code durch Middleware in ASP.NET Core neu schreiben?
ich habe gerade diesen Artikel teilweise lesen https://docs.microsoft.com/en-us/aspnet/core/migration/http-modules
mir bitte im Detail führen. Danke
es Dosis nicht umleiten die Seite sollte umgeleitet werden, aber es bewegt sich nicht – 1AmirJalali