Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 511
ne4istb Avatar asked Jan 31 '26 10:01

ne4istb


1 Answers

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" />
like image 81
SuperRembo Avatar answered Feb 02 '26 08:02

SuperRembo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!