繁体   English   中英

从 iPad 连接到 Visual Studio (IIS Express) 时出现登录问题

[英]Login issue when connecting to Visual Studio (IIS Express) from iPad

我有一个部署到 Azure 的 MVC5 应用程序。现在,为了在本地测试它,我使用 Visual Studio (2019) 运行我的应用程序,然后在我的移动设备浏览器中启动该站点。

问题是,当我从我的 iPad 执行此操作并登录时,输入用户名/密码并单击登录后,我立即返回到登录屏幕。

我在 iPad 上试过不同的浏览器。我试过清除它们的缓存。 我已经重新启动了我的电脑和我的 iPad。仍然是同样的问题。 我没有看到任何错误。 但如果我使用我的 iPhone 登录或从桌面浏览器登录,它会起作用 如果部署到Azure,我可以从任何地方登录,包括iPad。

我在代码中调试,我什至看到登录成功并且返回URL是正确的URL:

 var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, true);
            switch (result)
            {
                case SignInStatus.Success:
                    await UserManager.SetLockoutEndDateAsync(user?.Id, new DateTimeOffset(DateTime.UtcNow));
                    await UserManager.ResetAccessFailedCountAsync(user?.Id);

                    return RedirectToLocal(returnUrl);

我什至试图通过将以下代码放在我的登录 POST 方法的顶部来强制执行:

                AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                
                System.Web.HttpContext.Current.Session.Clear();
                System.Web.HttpContext.Current.Session.Abandon();
                
                Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.Cache.SetNoStore();

有人可以帮忙吗? 谢谢你。

希望有一天这会节省某人的工作时间。 问题是由于 Startup.Auth.cs 中有 CookieSameSite:

       app.UseCookieAuthentication(new CookieAuthenticationOptions
       {
           ExpireTimeSpan = TimeSpan.FromDays(14),
           AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
           LoginPath = new PathString("/Account/Login"),
           SlidingExpiration = true,
           CookieSameSite = SameSiteMode.Strict,
           Provider = new CookieAuthenticationProvider
           {
               OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(TimeSpan.FromMinutes(30), (manager, user) => user.GenerateUserIdentityAsync(manager))
           }
       });  

一旦我删除CookieSameSite = SameSiteMode.Strict, ,它就开始工作了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM