I am trying to use the ASP.NET Web API Self-Host option with Windows authentication so I can determine the logged on user and ultimately accept or reject the user based on their
Are you sure you're getting through the authentication part? You could use fiddler to check whether the requests are actually going through or whether the server always responds with 401 Unauthorized (since you're using authentication).
You could also try to implement your own custom AuthorizeAttribute
and put breakpoints in it to make sure it gets hit (you'll want to override the OnAuthorization
method and see if that gets hit).
using System.Web.Http;
public class MyAuth : AuthorizeAttribute
{
public override void OnAuthorization(System.Web.Http.Controllers.HttpActionContext actionContext)
{
base.OnAuthorization(actionContext); //put breakpoint here
}
}
Also, make sure you're using the Authorize
attribute from System.Web.Http
, and not from System.Web.Mvc
. See here why.