I have an ASP.NET Web API application running on .NET 4.0 with MVC 4.0. This is running on IIS 7.5, Windows Server 2008 R2 Datacenter Edition.
When I make a HTTP GET request to myserver/api I get a response with HTTP status code 200 (or 401 if not logged in) with appropriate content.
But when I make a HTTP OPTIONS request to the same url I always get a response with status code 200 and an empty response body (Content-length = 0).
Also I get this response when I make a HTTP OPTIONS request to a non-existent url (for example, myserver/api/foo).
The OPTIONS verb is allowed in my web.config file.
The problem is present only on one server, others work correctly.
Why would this be happening?
IIS has a default OPTIONSVerbHandler that might catch the request before MVC does. If you remove that handler, your application should handle the request and return the correct response.
<system.webServer>
<handlers>
<remove name="OPTIONSVerbHandler" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With