title: 405 Method Not Allowed on WebAPI2 (OWIN)
body: <p>I am setting up a WebAPI endpoint for my API, but am having trouble getting my AngularJS calls to my PostRegister method to work.</p>
  
  <p>The webAPI and Angular are on separate sites.</p>
  
  <p>On the Startup.cs I have:</p>
  
  <pre><code>    public void Configuration(IAppBuilder app)
      {
          ConfigureOAuth(app);
  
          var config = new HttpConfiguration();
  
          WebApiConfig.Register(config);
          app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
          app.UseWebApi(config);
  
      }
  
      private void ConfigureOAuth(IAppBuilder app)
      {
          var oAuthServerOptions = new OAuthAuthorizationServerOptions
          {
              AllowInsecureHttp = true,
              TokenEndpointPath = new PathString(Paths.TokenPath),
              AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(30),
              Provider = Kernel.Get&lt;IOAuthAuthorizationServerProvider&gt;()
          };
          app.UseOAuthAuthorizationServer(oAuthServerOptions); 
  
          OAuthBearerOptions = new OAuthBearerAuthenticationOptions();
          app.UseOAuthBearerAuthentication(OAuthBearerOptions);
      }
  </code></pre>
  
  <p>Then on the controller, I have my method that is set to allow anonymous:</p>
  
  <pre><code>    [AllowAnonymous]
      public bool PostRegister(UserSignupForm form)
      {
          ...
      }
  </code></pre>
  
  <p>I've also updated the web.config:</p>
  
  <pre><code> &lt;system.webServer&gt;
      &lt;handlers&gt;
        &lt;remove name="ExtensionlessUrlHandler-Integrated-4.0" /&gt;
        &lt;remove name="OPTIONSVerbHandler" /&gt;
        &lt;remove name="TRACEVerbHandler" /&gt;
        &lt;add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /&gt;
      &lt;/handlers&gt;
    &lt;/system.webServer&gt;
  </code></pre>
  
  <p>On the Angular side, I make a simple $http.post call:</p>
  
  <pre><code>    saveRegistration: function (registration) {
          return $http.post(baseUrl + '/api/signup/register', registration).then(function (response) {
              return response;
          });
      }
  </code></pre>
  
  <p>When making the call using Postman, I get a successful response, but when doing the same call from Angular, I get the 405 error.</p>
  
  <p><img src="https://i.stack.imgur.com/hgik0.png" alt="405 Method Not Allowed"></p>
  
  <p>BitOfTech sample site, is sending the same request headers, but is able to get the Access-Control-Allow-XXX headers</p>
  
  <p><img src="https://i.stack.imgur.com/jITKi.png" alt="enter image description here"></p>
  
  <p>I've updated my code to follow <a href="http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/" rel="noreferrer">Token Based Authentication using ASP.NET Web API 2, Owin, and Identity</a></p>