更新时间:2023-02-24 22:27:48
问题是默认情况下,您将配置OWIN中间件以重定向到"/Account/Login"以进行Cookie身份验证.
The problem is that you will have the OWIN middleware configured by default to redirect to "/Account/Login" for cookie authentication.
打开/AppStart/Startup.Auth.cs并编辑以下代码块以定位我们自己的URL:-
Open /AppStart/Startup.Auth.cs and edit the following block of code to target our own URL :-
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);