Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CORS Options Preflight Hanging

I have a ASP Web API project that is being hosted over SSL. I have another ASP MVC project that makes use of the API. While debugging, I am seeing behavior where the OPTIONS requests are hanging often (but not always) and preventing the other calls from proceeding.

In the Chrome debugger, these are just shown as 'Pending'. If launch Fiddler, everything works fine. I see no errors at all, things just hang. This fails before it hits the authorization code, so I can't even set any breakpoints.

Could this be a certificate problem? Firewall?

like image 632
AdamC Avatar asked Apr 19 '13 00:04

AdamC


People also ask

How do you handle CORS preflight request?

A CORS preflight request is a CORS request that checks to see if the CORS protocol is understood and a server is aware using specific methods and headers. It is an OPTIONS request, using three HTTP request headers: Access-Control-Request-Method , Access-Control-Request-Headers , and the Origin header.

How does a CORS preflight work?

CORS also relies on a mechanism by which browsers make a "preflight" request to the server hosting the cross-origin resource, in order to check that the server will permit the actual request. In that preflight, the browser sends headers that indicate the HTTP method and headers that will be used in the actual request.

How do I identify CORS preflight request?

Check for the existence of these essential information present in a preflight request: The request's HTTP method is OPTIONS. It has an Origin header. It has an Access-Control-Request-Method header, indicating what's the actual method it's trying to use to consume your service/resource.

What are CORS options?

OPTIONS requests are what we call pre-flight requests in Cross-origin resource sharing (CORS) . They are necessary when you're making requests across different origins in specific situations.


1 Answers

Could you try this: adding following node in web.config.

<system.webServer>
    <handlers>
         <!-- your other handlers -->
         <remove name="OPTIONSVerbHandler" />
    </handlers>
</system.webServer>
like image 157
Troy Dai Avatar answered Sep 26 '22 02:09

Troy Dai