CORS and IIS

I’ve been using the filter I wrote about in previous blog entry in dev for a while, and it worked fine. So I’m pushing the app to the IIS, and it stops working – fails on option request.

Weird thing was the response wasn’t what I was expecting, and when attaching debugger to IIS process – it was clear that filter wasn’t firing.

 

My request headers were along these lines:

 

Request URL:http://www.mydomain.com/api/v1/Application

Request Method:OPTIONS

Status Code:200 OK

Request Headersview source

Accept:*/*

Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3

Accept-Encoding:gzip,deflate,sdch

Accept-Language:en-US,en;q=0.8

Access-Control-Request-Headers:origin, x-requested-with, accept

Access-Control-Request-Method:GET

 

And response was this:

 

Response Headersview source

Allow:OPTIONS, TRACE, GET, HEAD, POST

Content-Length:0

Date:Wed, 19 Dec 2012 06:58:02 GMT

Public:OPTIONS, TRACE, GET, HEAD, POST

Server:Microsoft-IIS/8.0

X-Powered-By:ASP.NET

 

Obviously not something my filter would return, so I went to IIS to see if something would handle the OPTIONS request before it gets to the application, and found an OPTIONSVerbHandler in Handler Mappings. This returns.. well, see above, which is not what I want – so deleted it from the site, and boom – it worked.

Leave a Reply

Your email address will not be published. Required fields are marked *