c# - How to change route in WebApi+Odata project -


i'm re-implementing wcf service , choose use webapi 2.2 + odata v4. problem i'm facing need have route contains '_' , i'm unable implement it. have this:

public class annotationsharedwithcontroller : odatacontroller {     ...     [enablequery]     public iqueryable<annotationsharedwith> get()     {         return _unitofwork.annotationsharedwith.get();     }     ... } 

and webapiconfig.cs looks this:

public static void register(httpconfiguration config) {     config.mapodataserviceroute("webservice",null,generateedmmodel());         config.count(); }  private static iedmmodel generateedmmodel() {     var builder = new odataconventionmodelbuilder();     builder.entityset<annotationsharedwith>("annotation_shared_with");         return builder.getedmmodel(); } 

when issue request receive following error

{ "message": "no http resource found matches request uri 'http://localhost:12854/annotation_shared_with'.", "messagedetail": "no type found matches controller named 'annotation_shared_with'." }

by default odata search annotation_shared_withcontroller defined in edm model. since controller named annotationsharedwithcontroller return 404.

renamaing controller class solve issue. end messy class names.

you can implement own routing conventions, see routing conventions in asp.net web api 2 odata more details

hope helps.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -