asp.net mvc - AttributeRouting WebAPI Now Producing Errors -
i've updated (from v3.x) latest version of attributerouting on webapi project , it's started produce errors i've never seen before.
now whenever call made api error this:
system.invalidoperationexception: constraint entry 'inboundhttpmethod' on route route template 'my/path' must have string value or of type implements 'ihttprouteconstraint'. @ system.web.http.routing.httproute.processconstraint(httprequestmessage request, object constraint, string parametername, httproutevaluedictionary values, httproutedirection routedirection) @ system.web.http.routing.httproute.processconstraints(httprequestmessage request, httproutevaluedictionary values, httproutedirection routedirection) @ system.web.http.routing.httproute.getroutedata(string virtualpathroot, httprequestmessage request) @ attributerouting.web.http.framework.httpattributeroute.getroutedata(string virtualpathroot, httprequestmessage request) @ system.web.http.webhost.routing.httpwebroute.getroutedata(httpcontextbase httpcontext) @ system.web.routing.routecollection.getroutedata(httpcontextbase httpcontext) @ system.web.routing.urlroutingmodule.postresolverequestcache(httpcontextbase context) @ system.web.routing.urlroutingmodule.onapplicationpostresolverequestcache(object sender, eventargs e) @ system.web.httpapplication.synceventexecutionstep.system.web.httpapplication.iexecutionstep.execute() @ system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously)
it's been working without issues months.
non of docs detail there usage changes. config file looks correct.
what has gone wrong? can't find else reporting this.
definitely in memory hosting type issue. recently, encounter same issue after updating mvc 5. looked on various posts , found 1 helped me out. here how solved this.
after installing library attribute routing, must have following in global.ascx file.
attributeroutinghttpconfig.registerroutes(globalconfiguration.configuration.routes);
in attributeroutinghttpconfig class, replace following code:
routes.maphttpattributeroutes();
with
routes.maphttpattributeroutes(cfg => { cfg.inmemory = true; cfg.autogenerateroutenames = true; cfg.addroutesfromassemblyof<any_api_controller>(); });
here, any_api_controller refers of apicontroller class project.
Comments
Post a Comment