2015-12-02 20 views
1

尝试执行最简单的测试用例,以便在IIS 8上托管Web API ASPNET 5模板后获取已登录的用户名。在IIS 8上为Web api启用Windows身份验证的步骤asp.net 5站点

所以此工程在我的本地(IIS快递)

[HttpGet] 
    public IEnumerable<string> Get() 
    {    
     var name = System.Security.Principal.WindowsIdentity.GetCurrent().Name; 
     return new string[] { name, "value2" }; 
    } 

但是当我部署到服务器(只有启用了Windows身份验证),它显示的名称作为IIS应用程序池标识的网站。

我回顾了这个答案Why is there no authentication for the asp.net 5.0 preview - web api template -但我不确定它是否会专门用于Windows身份验证。

只是需要一些指导,感谢

回答

0

确保您的应用包括app.UseIISPlatformHandler()(beta8或更高版本)。然后检查HttpContext.User