Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have created a WEBAPI (ASP.NET and using Microsoft.AspNet.OData packages to have a V4 version of OData.
In my own defined OData Controllers (based on stored procedures exposed via Entity Framework) I have Get Methods to retrieve data. I use annotation
C#
[ODataRoute("GlobalProjectSearches?searchText={searchText}")]

In the webapi.config the controller is defined as:
C#
modelBuilder.EntitySet<GlobalProjectSearch_Result>("GlobalProjectSearches")
               .EntityType.Collection.Action("Get")
               .ReturnsCollectionFromEntitySet<GlobalProjectSearch_Result>("GlobalProjectSearches")
               .Parameter<string>("searchText");


That works OK and publishing to IIS is not a problem at all.
When running the project I can call the GlobalProjectSearches with or without the searchText parameter.
In IIS it shows an url like:
HTML
http://wrk2198:80/MarinServices/GlobalProjectSearches?searchText='Foo'


I have a website that connects to the OData webapi and when calling the GlobalProjectSearches it creates an URL Like
HTML
http://wrk2198:80/MarinServices/GlobalProjectSearches(searchText='Foo')
. That URL leads of course to a 404 error

What I have tried:

How can I have the proper URL created by the website when calling the connected service?
So why does my Website not stick to the OData route given to the controller?
Posted
Updated 11-Feb-20 4:22am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900