Asp.net mvc ASP.net表单身份验证在iis上不起作用
我正在进行基于Windows的身份验证,我的配置如下所示 web.config 授权书 允许角色=“管理员” 允许角色=“超级用户”/> 拒绝用户=“*” 授权书Asp.net mvc ASP.net表单身份验证在iis上不起作用,asp.net-mvc,windows-authentication,Asp.net Mvc,Windows Authentication,我正在进行基于Windows的身份验证,我的配置如下所示 web.config 授权书 允许角色=“管理员” 允许角色=“超级用户”/> 拒绝用户=“*” 授权书 在global.asax.cs中 void Application_AuthenticateRequest(object sender, EventArgs e) { string message = string.Empty; if (HttpContext.Current.Use
在global.asax.cs中
void Application_AuthenticateRequest(object sender, EventArgs e)
{
string message = string.Empty;
if (HttpContext.Current.User.Identity.IsAuthenticated)
message = HttpContext.Current.User.Identity.Name + " login successfully !";
else
message = HttpContext.Current.Request.UserHostAddress + " login failure !";
}
这在卡西尼号上非常有效。我可以登录到应用程序
当我在启用windows身份验证的IIS 7中托管它时
我正在获取未设置为对象实例的对象引用
这是因为出于某种原因,HttpContext.Current.User为null
由于某些原因,没有在httpcontext中设置用户
请帮我解决这个问题
提前感谢。iis应用池中的托管管道已设置为“集成”。 启用此选项后,不会在应用程序\u AuthenticateRequest事件上设置httpcontext。 要访问httpcontext,现在还为时过早 因此,我将逻辑移到着陆控制器方法中的适当位置,它成功了 谢谢