Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在IIS 7.5中使用Windows身份验证返回网站上的当前用户_C#_Iis 7_Windows Authentication - Fatal编程技术网

C# 在IIS 7.5中使用Windows身份验证返回网站上的当前用户

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>

使用IIS 7.5,返回当前windows用户需要哪些IIS设置、web.config设置和C#代码

Web.config值为

<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
是否不是您所期望的?