asp.net mvc 5 - Why MVC5 gives this error "The requested resource does not support http method 'OPTIONS' "? -
i have updated application mvc4 mvc5, when run mvc4 works fine mvc5 gives error {"message":"the requested resource not support http method 'options'."}
in fiddler.
1) *request application of mvc5 in fiddler : *
options /api/controller/method http/1.1 host: example.com connection: keep-alive access-control-request-method: post origin: http://wyx.com user-agent: mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/33.0.1750.146 safari/537.36 access-control-request-headers: referer, content-type accept: */* referer: exampleimage.gif accept-encoding: gzip,deflate,sdch accept-language: en-gb,en-us;q=0.8,en;q=0.6
*response of mvc5 application in fiddler : *
http/1.1 405 method not allowed cache-control: no-cache pragma: no-cache **allow: post** content-type: application/json; charset=utf-8 expires: -1 server: microsoft-iis/7.5 x-aspnet-version: 4.0.30319 x-powered-by: asp.net access-control-allow-origin: * access-control-allow-headers: origin, x-requested-with, content-type, accept date: mon, 10 mar 2014 13:32:48 gmt content-length: 76
2) ** request application of mvc4 in fiddler **
options /api/controller/method http/1.1 host: example.com connection: keep-alive access-control-request-method: post origin: http://wyx.com user-agent: mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/33.0.1750.146 safari/537.36 access-control-request-headers: referer, content-type accept: */* referer: exampleimage.gif accept-encoding: gzip,deflate,sdch accept-language: en-gb,en-us;q=0.8,en;q=0.6
*response of mvc5 application in fiddler : *
http/1.1 200 ok **allow: options, trace, get, head, post** server: microsoft-iis/7.5 public: options, trace, get, head, post x-powered-by: asp.net access-control-allow-origin: * access-control-allow-headers: origin, x-requested-with, content-type, accept date: mon, 10 mar 2014 13:54:08 gmt content-length: 0
why in mvc4 allow " allow: options, trace, get, head, post , in mvc5 : allow: post
i tried in mvc5 in web.config ::
<system.webserver> <modules runallmanagedmodulesforallrequests="true"> </modules> <httpprotocol> <customheaders> <remove name="access-control-allow-origin" /> <add name="access-control-allow-origin" value="*" /> <add name="access-control-allow-headers" value="*" /> <add name="access-control-allow-methods" value="*" /> </customheaders> </httpprotocol> </system.webserver>
but it's not working.
can check api initializer , verify have
globalconfiguration.configure(webapiconfig.register);
instead of
webapiconfig.register(globalconfiguration.configuration);
this fixed exact same issue me. errors indicate routes not set @ ;)
Comments
Post a Comment