。IIS核心和Windows身份验证在IIS 8失败
问题描述:
我有一个.Net核心1.0 Web应用程序的目标框架4.6使用Windows身份验证(Intranet站点)。它在IIS Express下的开发环境中运行良好。。IIS核心和Windows身份验证在IIS 8失败
在startup.cs我:
services.Configure<IISOptions>(options => {
options.ForwardWindowsAuthentication = true;
});
一旦在Windows Server 2012,但上线的应用程序出现了错误部署到IIS 8:
var userName = context.User.Identity.Name;
以“未将对象引用设置为一个对象的实例“错误。在web.config中,我有:
<system.web>
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
</system.web>
在IIS管理器中的“身份验证”的网站,一切都只是“Windows身份验证”以及禁用。在IIS中使用相同设置的同一台服务器上的另一个ASP.NET MVC 4站点正常工作。还有什么我可以尝试得到这个工作?
答
的配置设置如下解决这个问题,特别是forwardWindowsAuthToken =真:
<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>