即使在第一次刷新后,MVC5身份验证也会重定向到登录页面

时间:2020-11-09 12:36:28

标签: c# asp.net-mvc-5 owin

我正在开发一个ASP.NET MVC 5项目,它在本地运行良好,但是在服务器上部署后,我使用OWIN进行身份验证,它在首次登录时运行良好,但是几秒钟后,如果刷新页面,它会将我重定向回登录页面。

此代码用于启动:

 app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/ar/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))
            }
        });   

0 个答案:

没有答案
相关问题