Reputation: 1450
I have an Web API application. My Angular web UI calls the web API. I have modified the application to make the http calls like below
var urlString = SomeSettings.apiServiceBaseUri + 'api/Test';
var getData = function (urlString) {----}
I also have enabled the Cors in Web Api config as below.
//Enable Cors
//Right now adding URLs for Dev and QA
var cors = new EnableCorsAttribute("http://DevAPIURL.com, http://QAAPIURL.com", "*", "*");
// var cors = new EnableCorsAttribute("*", "*", "*");
cors.SupportsCredentials = true;
config.EnableCors(cors);
With this setting, if I am debugging the application I am getting the "XMLHttpRequest: Network Error 0x80070005, Access is denied." error. I dont see the access-control-allow-origin header in fiddler as well
However if I use * instead of the domain names, I am able to work.
What else is going wrong in this.
Upvotes: 0
Views: 181
Reputation: 1450
I got this working. Some one in another thread also had suggested but I kind of ignored that. Here is the solution
I installed the Microsoft.Owin.Cors and then in the startup.Auth.cs class I added the below line as the 2st line in ConfigureAuth method.install-package Microsoft.Owin.Cors
Thats it.
I removed the configuration from WebWPIConfig.cs class.
Testted both authentication and API Controller method all worked.
Upvotes: 1