1
votes

Trying to do the simplest possible test case to get the logged in user name in a Web API ASPNET 5 template, after it's hosted on IIS 8.

So this works on my local (IIS Express)

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

but when I deploy to the server (having only Windows Authentication enabled) it shows the name as the IIS Apppool identity for the site.

I reviewed this answer Why is there no authentication for the asp.net 5.0 preview - web api template - but I'm not sure if it will work specifically for Windows Authentication.

Just need some direction, thanks

1

1 Answers

0
votes

Make sure your app includes app.UseIISPlatformHandler() (beta8 or later). Then check HttpContext.User.