Asp.net core Asp.net核心MVC登录路径不工作
我在Startup.cs ConfigureServices方法中将loginpath设置为以下代码Asp.net core Asp.net核心MVC登录路径不工作,asp.net-core,asp.net-core-mvc,Asp.net Core,Asp.net Core Mvc,我在Startup.cs ConfigureServices方法中将loginpath设置为以下代码 services.Configure<CookieAuthenticationOptions>(options => { options.AutomaticAuthenticate = true; options.LoginPath = new PathString("/Content/Index"); options.LogoutPath = new
services.Configure<CookieAuthenticationOptions>(options =>
{
options.AutomaticAuthenticate = true;
options.LoginPath = new PathString("/Content/Index");
options.LogoutPath = new PathString("/Content/Index");
});
services.Configure(选项=>
{
options.AutomaticAuthenticate=true;
options.LoginPath=新路径字符串(“/Content/Index”);
options.LogoutPath=新路径字符串(“/Content/Index”);
});
但它没有重定向到此路径,它将继续重定向到“/Account/Login?ReturnUrl=%2F”
我读了一些与此相关的问题,但找不到任何有效的解决方案。我在错误的部分配置了它。在Startup.cs Configure方法中,我添加了以下代码,它可以正常工作
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
LoginPath = new PathString("/giris")
});
请注意,app.UseCookiAuthentication应放在app.UseMvc之前。