2011-11-08 39 views
0

工作,所以我必须使用Windows Authenication只能做一件事情一个ASP.NET网站:ASP.NET Windows身份验证不是在IIS 7.5

protected void Page_Load(object sender, EventArgs e) 
    { 
     somelabel.Text = HttpContext.Current.User.Identity.IsAuthenticated.ToString(); 
     return; 
    } 

遗憾的是,总是出于某种原因误。这是我的web.config

<configuration> 
<system.web> 
<compilation debug="true" targetFramework="4.0"/> 
<authentication mode="Windows"/> 
<authorization> 
    <allow users="*"/> 
</authorization> 
<customErrors mode="Off"/> 
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/> 
</system.web> 
<system.webServer> 
<modules runAllManagedModulesForAllRequests="true"/> 
</system.webServer> 
</configuration> 

我部署它在我的Windows 7运行IIS 7.5。

  • Windows身份验证已安装并启用
  • 目标框架是4.0
  • 应用程序池管道的事情被集成
  • 在Windows身份验证的扩展保护是“关”和“接受”(尝试都)

回答

3

更改的授权部分:

<authorization> 
    <deny users="?"/> 
</authorization> 

我认为通过说allow users="*"你是让每个人都可以访问。

看到这个职位由Scott Guthrie

+0

你的意思是拒绝用户= “?”。你写的只允许匿名用户 –

+0

@simonhalsey我打算从Scott的博客复制web.config的那一部分,但显然没有做到这一点。它现在得到了纠正,非常感谢! – Icarus