0

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));

        }
Cœur
  • 37,241
  • 25
  • 195
  • 267
  • Is the request made over https, as your error suggest it requires https. – Chandermani Apr 30 '14 at 11:44
  • I found, i'm just disabled ssl required "RequireSsl = false" and start to work var authConfig = new AuthenticationConfiguration { RequireSsl = false, InheritHostClientIdentity = true, ClaimsAuthenticationManager = FederatedAuthentication.FederationConfiguration.IdentityConfiguration.ClaimsAuthenticationManager }; – user3083705 Apr 30 '14 at 12:03

0 Answers0