asp.net mvc - What is the proper way to scope OData methods to single controller? -
i have webapi 2 controllers working side side single odata controller in same project. trying set needed routing configuration:
- all request /api should mapped odatacontroller
- all other requests should directed ordinary web api controllers
when try map /api route odata contoller this:
class webapiconfig { public static void register(httpconfiguration configuration) { configuration.routes.maphttproute("api default", "api/{action}/{id}", new { controller = "apiodata", id = routeparameter.optional }); odatamodelbuilder builder = new odataconventionmodelbuilder(); builder.entityset<organization>("organizations"); configuration.routes.mapodataserviceroute( routename: "odataroute", routeprefix: "api", model: builder.getedmmodel()); } }
all method calls work fine both web api , odata controller, such requests /api/$metadata not work.
when remove "api default" route - requests odata controller methods such /api/organizations stops working (returning 404) /api/$metadata begins to.
detailed 404 error message:
<error> <message> no http resource found matches request uri 'http://localhost:53576/api/organizations'. </message> <messagedetail> no type found matches controller named 'organizations'. </messagedetail> </error>
what proper way map odata calls single controller actions?
Comments
Post a Comment