asp.net - WebApi cannot get PUT to work -
im testing webapi web service on local machine. cant set work. have next response service:
http/1.1 405 method not allowed cache-control: no-cache pragma: no-cache allow: get,post content-type: application/json; charset=utf-8 expires: -1 server: microsoft-iis/8.0 x-aspnet-version: 4.0.30319 x-sourcefiles: =?utf-8?b?qzpcvxnlcnncshzhcnjlz2fhcmrcrg9jdw1lbnrzxeryb3bib3hcr3jlzw5xzwjcs3vuzgvyxe1hzhmgtw9nzw5zamo4alxetezcrexgu2vydmljzvxeteztzxj2awnlxgfwavxhy3rpb25wbgfuywn0aw9u?= x-powered-by: asp.net access-control-allow-origin: * access-control-allow-methods: get,put,post,delete,options access-control-allow-headers: content-type date: tue, 24 jun 2014 06:55:02 gmt content-length: 72 {"message":"the requested resource not back upwards http method 'put'."}
i have added cors nuget bundle , has next setup:
public static class webapiconfig { public static void register(httpconfiguration config) { // web api configuration , service //enable cross origin requests (cors) var cors = new enablecorsattribute("*", "*", "*"); config.enablecors(cors); // web api routes config.maphttpattributeroutes(); config.routes.maphttproute( name: "defaultapi", routetemplate: "api/{controller}/{id}/{secondid}", defaults: new { id = routeparameter.optional, secondid=routeparameter.optional } ); //configures homecoming json if request accepts text/html config.formatters.jsonformatter.supportedmediatypes.add(new mediatypeheadervalue("text/html")); } }
my web.config looks (its bits , pieces found around so):
<system.webserver> <validation validateintegratedmodeconfiguration="false" /> <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" /> <add name="apiuris-isapi-integrated-4.0" path="/security/*" verb="get,post, put, delete" type="system.web.handlers.transferrequesthandler" precondition="integratedmode,runtimeversionv4.0"/> <add name="settingshandler" path="/api/settings/*" verb="*" type="system.web.handlers.transferrequesthandler" precondition="integratedmode,runtimeversionv4.0"/> <add name="sendhandler" path="/send/*" verb="get" type="system.web.handlers.transferrequesthandler" precondition="integratedmode,runtimeversionv4.0"/> <remove name="extensionlessurlhandler-integrated-4.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> <httpprotocol> <customheaders> <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="content-type" /> </customheaders> </httpprotocol> <modules runallmanagedmodulesforallrequests="false"> <remove name="webdavmodule" /> </modules> </system.webserver>
it seems not allow me send put, , post. cant figure out how enable set command.
asp.net asp.net-web-api
No comments:
Post a Comment