Well, this was one of those bugs that took a while to figure out and of course the solution was pretty simple.
It turns out that this:
[EnableCors(origins: “http://MyWebsite.com”, headers: “*”, methods: “*”)]
is not the same as this:
[EnableCors(origins:”http://mywebsite.com”, headers: “*”, methods: “*”)]
Failed to load http://myservice.com/api/SomeController/SomeMethod: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://mywebsite.com‘ is therefore not allowed access.
I tried a lot of things to figure out what was going on. I knew that I had the CORS attribute on my controller and I had config.EnableCors(); set up in my Web API configuration. This is one of the first times I’m using CORS on Azure so I thought it had something to do with Azure, but that was not correct. After trying many, many hacks with no success and staring at my EnableCors Attribute, I had the “crazy” idea to change “http://MyWebsite.com” to ”http://mywebsite.com” and of course, everything worked fine. From now on, I’ll use all lowercase!
I hope you won’t get stuck wasting as much time as I did trying to figure this one out!