I have the trouble with AuthenticationConfiguration, when I put the AuthenticationConfiguration in the WebApiConfig my $http request stop to work. I get error Failed to load resource: the server responded with a status of 403 (HTTPS Required.).
Angular request
$http.get(defaultUrl + '/' + 'IsLoggedIn');
public class AuthenticationServiceController : ApiController
{
[System.Web.Http.HttpGet]
public HttpResponseMessage IsLoggedIn()
{
var loged = System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
return Request.CreateResponse<bool>(System.Net.HttpStatusCode.OK, loged);
}
}
WebApiConfig.cs
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
var authConfig = new AuthenticationConfiguration
{
InheritHostClientIdentity = true,
ClaimsAuthenticationManager = FederatedAuthentication.FederationConfiguration.IdentityConfiguration.ClaimsAuthenticationManager
};
// setup authentication against membership
authConfig.AddBasicAuthentication((userName, password) => Membership.ValidateUser(userName, password));
config.MessageHandlers.Add(new AuthenticationHandler(authConfig));
}