Search code examples
asp.netasp.net-web-apiiis-7.5

IIS Config HTTP OPTIONS returns 200 but with empty response


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?


Solution

  • 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" />