web api - CORS Not working for OPTIONS -
public void configuration(iappbuilder app) { app.usecors(microsoft.owin.cors.corsoptions.allowall); }
in our webapiconfig.cs have following line @ top of register:
public static void register(httpconfiguration config) { config.enablecors();
in our web.config have following under
<handlers> <remove name="extensionlessurlhandler-isapi-4.0_32bit" /> <remove name="extensionlessurlhandler-isapi-4.0_64bit" /> <remove name="extensionlessurlhandler-integrated-4.0" /> <add name="extensionlessurlhandler-isapi-4.0_32bit" path="*." verb="get,head,post,debug,put,delete,patch,options" modules="isapimodule" scriptprocessor="%windir%\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll" precondition="classicmode,runtimeversionv4.0,bitness32" responsebufferlimit="0" /> <add name="extensionlessurlhandler-isapi-4.0_64bit" path="*." verb="get,head,post,debug,put,delete,patch,options" modules="isapimodule" scriptprocessor="%windir%\microsoft.net\framework64\v4.0.30319\aspnet_isapi.dll" precondition="classicmode,runtimeversionv4.0,bitness64" responsebufferlimit="0" /> <!--<remove name="optionsverbhandler" />--> <remove name="traceverbhandler" /> <add name="extensionlessurlhandler-integrated-4.0" path="*." verb="*" type="system.web.handlers.transferrequesthandler" precondition="integratedmode,runtimeversionv4.0" /> </handlers>
and following in httpprotocol.
<customheaders> <remove name="access-control-allow-origin" /> <remove name="access-control-allow-methods" /> <remove name="access-control-allow-headers" /> <add name="access-control-allow-origin" value="*" /> <add name="access-control-allow-methods" value="get,put,post,delete,options" /> <add name="access-control-allow-headers" value="origin, x-requested-with, content-type, accept/> </customheaders>
whenever options call fiddler, getting 405: here returned. looks me have set correctly, , access-control-allow-methods says options...so why isn't working?
http/1.1 405 method not allowed allow: content-length: 76 content-type: application/json; charset=utf-8 server: microsoft-iis/8.5 x-powered-by: asp.net access-control-allow-origin: * access-control-allow-methods: get,put,post,delete,options access-control-allow-headers: origin, x-requested-with, content-type, accept, amsconnect-version, authorization-token, amsconnect-environment date: wed, 29 apr 2015 13:26:43 gmt
can see wrong?
sounds server isn't accepting options requests. or maybe there's proxy in front of server refuses pass options requests through. try using simple diagnostic tool curl send options requests server. try doing directly on server first, then, if works, remote machine.
Comments
Post a Comment