Reputation: 9077
I've set up a REST api with ASP.NET Web API and enabled CORS like so:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
</system.webServer>
The jQuery ajax call works in Chrome and Safari but in Firefox I get a NetworkError: 405 Method Not Allowed
.
Do Firefox have some especially tough restrictions when the site is http://localhost
? Have I missed something in my Web.Config that FF needs?
Thanks!
## Edit:
It look like it's the OPTION method that does not work. The OPTION method is not allowed in Chrome either but Chrome goes ahead making the GET request anyway. Firefox gives 405 for the OPTION and then never makes the GET.
This is the request from chrome dev tools:
Upvotes: 3
Views: 2330
Reputation: 11
Try using fix domain instead of "*" solved the problem in our case
<add name="Access-Control-Allow-Origin" value="http://localhost" />
Upvotes: 1
Reputation: 112
I ran in the same situation. The options-keyword rose a 405 HTTP Error. Well, the solution was to switch from IISExpress (Development Application Server) to ISS 7.x. There are (of course) significant restrictions using a development web-server. This solved the issue you mentioned for me.
Upvotes: 0
Reputation: 2111
Can you try add following line under system.web -> handlers in web.config?
<remove name="OPTIONSVerbHandler" />
This default handler may block your option request
Upvotes: 0