Search code examples
c#asp.net-mvcodata

OData API with dot in Controller name


Right now I have an API that has some OData controllers. /api/Customers /api/Addresses

The Customers controller returns 1 or more customers holding an address collection. The Addresses controller returns Addresses

It is required from me to change the Addresses controller to have the following endpoint /api/Customers.Addresses

I find a lot of examples how to handle dots in parameters but not in the controller name itself.

What should be changed to handle this requirement?


Solution

  • If this is odata v4 you could use the ODataRoutePrefixAttribute. Decorate the controller with

    [ODataRoutePrefix("Customers.Addresses")]