2023-02-15 281
在我的ASP.NET Web表单应用程序中,我正在使用ASP.NET Identity 2.2进行成员资格系统.发展阶段按预期工作.用户获得身份验证并根据其角色访问网站的不同区域.
部署到IIS 10本地服务器后,身份验证被推翻.登录是成功的,但用户不进行身份验证.登录页面再次加载空和新鲜.我知道登录是通过在重定向前创建的文字创建的一些测试来成功的.
这是登录方法:
protected void LogIn(object sender, EventArgs e)
{
if (IsValid)
{
// Validate the user password
var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
var signinManager = Context.GetOwinContext().GetUserManager<ApplicationSignInManager>();
List<ApplicationUser> us = manager.Users.ToList();
foreach (var user in us)
{
textSuccess.Text += user.UserName + ": ";
foreach (var role in user.Roles)
{
textSuccess.Text += role.RoleId + ", ";
}
}
// This doen't count login failures towards account lockout
// To enable password failures to trigger lockout, change to shouldLockout: true
var result = signinManager.PasswordSignIn(Email.Text, Password.Text, true, shouldLockout: false);
switch (result)
{
case SignInStatus.Success:
panelSuccess.Visible = true;
IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
break;
case SignInStatus.LockedOut:
Response.Redirect("/Account/Lockout");
break;
case SignInStatus.RequiresVerification:
Response.Redirect(String.Format("/Account/TwoFactorAuthenticationSignIn?ReturnUrl={0}&RememberMe={1}",
Request.QueryString["ReturnUrl"],
RememberMe.Checked),
true);
break;
case SignInStatus.Failure:
default:
FailureText.Text = "Înregistrare eșuată";
ErrorMessage.Visible = true;
break;
}
}
}
我该怎么办?综合管道的Outin配置可能会出现问题吗?
最终,在进行解决分辨率的所有可能的路径之后,我发现问题是cookie身份验证的配置.我会在这里发布任何悲惨的研究人员.
在 startup.auth.cs中文件中,我有:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login.aspx"),
CookieSecure = CookieSecureOption.Always,
AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Active,
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
因为我在我的开发服务器上使用HTTPS,但不是在我部署了网站的IIS服务器上,所以 cookieseCureption.always 选项阻止了后者的身份验证.在这种情况下, cookieseCureption.sameasrequest 选项,这是默认的,是真正的正确选择.
以上所述是小编给大家介绍的为什么在本地部署ASP.NET 4.6应用程序到IIS 10服务器后,用户不能进行认证?,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!
原文链接:https://77isp.com/post/33804.html
=========================================
https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。
数据库技术 2022-03-28
网站技术 2022-11-26
网站技术 2023-01-07
网站技术 2022-11-17
Windows相关 2022-02-23
网站技术 2023-01-14
Windows相关 2022-02-16
Windows相关 2022-02-16
Linux相关 2022-02-27
数据库技术 2022-02-20
抠敌 2023年10月23日
嚼餐 2023年10月23日
男忌 2023年10月22日
瓮仆 2023年10月22日
簿偌 2023年10月22日
扫码二维码
获取最新动态