3

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?

4

1 回答 1

3

IIS 有一个默认的 OPTIONSVerbHandler 可能会在 MVC 之前捕获请求。如果您删除该处理程序,您的应用程序应该处理请求并返回正确的响应。

<system.webServer>
    <handlers>
        <remove name="OPTIONSVerbHandler" />
于 2013-08-27T06:40:28.203 回答