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.

Answers


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


You can manually do it using the ODataModelBuilder instead of the ODataConventionModelBuilder

e.g

        var builder = new ODataModelBuilder();
        builder.EntitySet<Order>("Employees");
        builder.EntitySet<Order>("employees"); 

this will work but your metadata will show 2 entity sets:

{
@odata.context: "http://localhost:62881/$metadata",
value: [
{
name: "Employees",
kind: "EntitySet",
url: "Employees"
},
{
name: "employees",
kind: "EntitySet",
url: "employees"
}
]
}

Need Your Help

How to delete cookies?

java browser cookies htmlunit

I want to delete cookies programmatically.

Error : unrecognized selector sent to instance

ios iphone objective-c ios7 uiinterfaceorientation

I got this error in app when i change orientations, i got it first time in life, i have never seen this type of error before,