OData CORS and datajs

Jan 9, 2013 at 5:25 PM


I'm having a problem with getting the datajs working with OData supporting CORS.

So when I'm sending a simple GET request to a server from FireFox this is how the raw request looks like:


OPTIONS http://xxx/dps/AnnotationTypes HTTP/1.1
Host: dubv-dpdiweb01.dubeng.local
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Origin: null
Access-Control-Request-Method: GET
Access-Control-Request-Headers: maxdataserviceversion


And the response from the server:


HTTP/1.1 501 Not Implemented
Cache-Control: private
Content-Length: 195
Content-Type: application/xml;charset=utf-8
Server: Microsoft-IIS/8.0
X-Content-Type-Options: nosniff
DataServiceVersion: 1.0;
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 1728000
Access-Control-Allow-Headers: Content-Type, Accept, Origin, X-Requested-With, MaxDataServiceVersion, DataServiceVersion, dptoken, role , platform
Access-Control-Allow-Methods: PUT, POST, GET, DELETE, MERGE, OPTIONS
Access-Control-Allow-Credentials: true
Date: Wed, 09 Jan 2013 17:10:55 GMT

Not Implemented


Chrome and IE also get the 501 response but they ignore it and next receive a proper response, so effectively communication with OData works fine in these browsers while FireFox gets stopped.

I was wondering if anyone who successfully implemented the OData service with CORS had similar issues. Is there anything obvious in the headers that I pasted here that would indicate a problem? It seems that the server doesn't like the OPTIONS request send by a browser and this is probably a reason for the Not Implemented message.


Feb 12, 2013 at 4:47 PM
As a temporary solution we used this: http://datajs.codeplex.com/discussions/265321 and it worked fine.
As a final solution to avoid cross-domain issues we are going to user reverse proxy.