Search code examples
asp.netasp.net-web-apiodataasp.net-web-api-routing

Is routes case-sensitive in Web API OData Service using ODataController?


i followed this to learn how ODataController works, everything is OK but when i changed the request uri
from

"localhost:49292/odata/Employees" //result: 200

to

"localhost:49292/odata/employees" //result: 404

to say one word: "odata" or "Odata" and "Employee" are all ok, but lowercase "employee" return 404. any explanation about this. Moreover, the routes in asp.net mvc is not case-sensitive afaik.


Solution

  • how about including a Route attribute and direct it to lower case. for Upper case web api will take care about it

    [Route("odata/employees")]

    add this on the top of the controller

    if odata is common for every action then you can include [RoutePrefix] attribute