iis 8 - . net Core和Windows认证失败



我有一个。net Core 1.0 web应用程序,目标框架4.6,使用Windows认证(内部网站点)。它在IIS Express下的开发环境下运行良好。

在startup.cs中我有:

services.Configure<IISOptions>(options => {
            options.ForwardWindowsAuthentication = true;
          });
然而,一旦部署到Windows Server 2012中的IIS 8,应用程序就会出错:
var userName = context.User.Identity.Name;

出现"对象引用未设置为对象的实例"错误。在网络上。

    <system.web>
       <authentication mode="Windows" />
       <authorization>
          <deny users="?" />
       </authorization>
    </system.web>

在IIS管理器中,站点的"身份验证"下,除了"Windows身份验证"之外,所有内容都被禁用。另一个ASP。. NET MVC 4站点在同一台服务器上使用相同的IIS设置可以正常工作。还有什么我可以试着让这个工作吗??

下面的Config设置解决了这个问题,特别是forwardWindowsAuthToken=true:

  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="<path to app>"  arguments="" stdoutLogEnabled="true" stdoutLogFile="<outpath>" forwardWindowsAuthToken="true" />
        <security>
            <authentication>
                <anonymousAuthentication enabled="false" />
            </authentication>
        </security>
  </system.webServer>

最新更新