I have a set of webapi which accepts cross domain requests. So, I have these customheaders setup in web.config
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="*" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
This has been working fine with cross domain request for a long time.
Now, I added a new method for an web api endpoint to accept file uploads. I tried to call this webapi from a different domain, and I get a "405 method not allowed" response from the server. The request method is OPTIONS.
Now before anyone closes this as duplicate, let me clarify that I have seen examples with other approach like EnableCors attributes. So, my question is not how to accept cross domain requests. As already mentioned above, I have been accepting cross domain request on other endpoints for quite sometime.
My questions are: a) Why is the call to this particular endpoint (with OPTIONS method request) ending in a 405 error, while other endpoints work fine? (please note that "Access-Control-Allow-Methods" value has OPTIONS included in value). b) how to resolve this problem, and get the api call to go successfully? (without going for other approaches like enablecors atribute)