C# 在IIS 7.5中使用Windows身份验证返回网站上的当前用户
使用IIS 7.5,返回当前windows用户需要哪些IIS设置、web.config设置和C#代码 Web.config值为C# 在IIS 7.5中使用Windows身份验证返回网站上的当前用户,c#,iis-7,windows-authentication,C#,Iis 7,Windows Authentication,使用IIS 7.5,返回当前windows用户需要哪些IIS设置、web.config设置和C#代码 Web.config值为 <authentication mode="Windows"> <identity impersonate="true" /> <windowsAuthentication enabled="true"> <providers>
<authentication mode="Windows">
<identity impersonate="true" />
<windowsAuthentication enabled="true">
<providers>
<add value="Negotiate" />
<add value="NTLM" />
</providers>
</windowsAuthentication>
应用程序配置值为
<authentication mode="Windows">
<identity impersonate="true" />
<windowsAuthentication enabled="true">
<providers>
<add value="Negotiate" />
<add value="NTLM" />
</providers>
</windowsAuthentication>
似乎不要这样做。确保在Visual Studio项目的属性中将Windows身份验证设置为已启用。在项目文件(.csproj)中,这转换为:
<IISExpressWindowsAuthentication>enabled</IISExpressWindowsAuthentication>
已启用
另外,将托管管道模式项目属性设置为经典:
<IISExpressUseClassicPipelineMode>true</IISExpressUseClassicPipelineMode>
true
到底什么不起作用?当您访问时,是否向您提供了用户名/密码框?User.Identity.Name
是否不是您所期望的?