I am setting up a WebAPI endpoint for my API, but am having trouble getting my AngularJS calls to my PostRegister method to work.
The webAPI and Angular are on separate sites.
On the Startup.cs I have:
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<IOAuthAuthorizationServerProvider>()
};
app.UseOAuthAuthorizationServer(oAuthServerOptions);
OAuthBearerOptions = new OAuthBearerAuthenticationOptions();
app.UseOAuthBearerAuthentication(OAuthBearerOptions);
}
Then on the controller, I have my method that is set to allow anonymous:
[AllowAnonymous]
public bool PostRegister(UserSignupForm form)
{
...
}
I've also updated the web.config:
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
On the Angular side, I make a simple $http.post call:
saveRegistration: function (registration) {
return $http.post(baseUrl + '/api/signup/register', registration).then(function (response) {
return response;
});
}
When making the call using Postman, I get a successful response, but when doing the same call from Angular, I get the 405 error.

BitOfTech sample site, is sending the same request headers, but is able to get the Access-Control-Allow-XXX headers

I've updated my code to follow Token Based Authentication using ASP.NET Web API 2, Owin, and Identity


PostRegister()function is nothing like any function in the code on the site, and doesn't seem to match the signature of the angular.js$http.postmethod either. - Claies