I have side-by-side Web API 2.2 APIController and OData v4 ODataController. My APIController uses the routing attributes internally (there are no predefined defaults for routing):
[RoutePrefix("api")] public class MyController : ApiController { [HttpGet] [Route("My")] public IHttpActionResult Get() {
and as such are sent through. / api / my and. / api / my /? mykey = value
and I tried to configure my ODataController to execute a similar option:
[ODataRoutePrefix("My")] public class oMyController : ODataController { [HttpGet] public IHttpActionResult Get(ODataQueryOptions<FileModel> queryOptions) {
odata route determination ahead of time:
ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); builder.EntitySet<MyModel>("My"); config.MapODataServiceRoute( routeName: "ODataRoute", routePrefix: "odata", model: builder.GetEdmModel() );
but trying to access. / odata / My and. / odata / My (value) end up in my APIC controller instead of the ODataController.
How can I send them using different prefixes, but with the same name, and ask them to go to the corresponding controllers. I do not want to have a different name for each route, if I can prevent it, prefixes should take care of everything, but for some reason this is not so.
c # odata asp.net-web-api asp.net-web-api-routing odata-v4
Xorcist
source share