asp.net 4.0で、我々は今、どうやってできた私に教えて、このようASP.Net MVC:どのようにミドルウェアでURLを書き換えるASP.NETコアで
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);
}
}
のようなモジュールを書き換えるために、HTTPモジュールで作業を使用することができます上記のコードをASP.NET Coreのミドルウェアで書き直しますか?
私は部分的にhttps://docs.microsoft.com/en-us/aspnet/core/migration/http-modules
詳細に私を導いてくださいこの記事を読んだことがあります。ありがとう
ページはリダイレクトされませんが、リダイレクトされるはずですが、移動しません – 1AmirJalali