I have a Web Api 2.2 project working with OData v4. The normal EntitySet configuration is working as desired with all http verbs. Where I am having a problem is trying to
Please change the element as below, which is the recommended way if there is dot in the request URL:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
and if
http://something/odata/Products/ProductService.MostExpensive()
is requested, I can get the data:
{
@odata.context: "http://localhost:14853/odata/$metadata#Edm.Double",
value: 3
}
Then you may try adding the part not replacing them. Mine looks like below and it can work.
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<clear/>
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="/*"
verb="*" type="System.Web.Handlers.TransferRequestHandler"
preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
I know this question is not recent, but I found another answer that works for me. If you're willing to remove the namespace from the URL, you can use
config.EnableUnqualifiedNameCall(true);
Your URL would then look like this:
http://something/odata/Products/MostExpensive
See http://odata.github.io/WebApi/#06-01-custom-url-parsing. That's available in the Microsoft.AspNet.OData NuGet package.