iis - OData queries give 404 error unless I add a trailing slash -


i created dummy project test odata in vs2015 , having same issue described in question, , code largely equivalent described there. web api 2: odata 4: actions returning 404

any query bound function gives 404 error until add trailing slash. example:

http://localhost:46092/odata/v1/trips/default.gettripnamebyid - 404 http://localhost:46092/odata/v1/trips/default.gettripnamebyid/ - works expected

http://localhost:46092/odata/v1/trips/default.gettripnamebyid(tripid=1)?$select=name - 404 http://localhost:46092/odata/v1/trips/default.gettripnamebyid(tripid=1)/?$select=name - works expected

this not supposed happen because microsoft documentation never mentions trailing slash required, examples supposed work without them. also, breaks swagger ui doesn't add trailing slash , gets 404 when trying make query.

what reason behaviour? how make work without slash, seems normal expected behaviour?

here code snippets:

tripscontroller.cs:

    ...     [httpget]     public ihttpactionresult gettripnamebyid(int tripid)     {         return ok(demodatasources.instance.trips.asqueryable().where(t => t.id == tripid.tostring()));     } 

webapiconfig.cs:

public static void register(httpconfiguration config)     {         config.maphttpattributeroutes();          config.mapodataserviceroute("odata", "odata/v1", getedmmodel());  defaultodatabatchhandler(globalconfiguration.defaultserver));         config.ensureinitialized();     }      private static iedmmodel getedmmodel()     {         odataconventionmodelbuilder builder = new odataconventionmodelbuilder();         builder.entityset<person>("people");         builder.entityset<trip>("trips");          builder.entitytype<trip>().collection.function("gettripnamebyid").returns<string>().parameter<int>("tripid");          var edmmodel = builder.getedmmodel();         return edmmodel;     } 

it turns out web.debug.config ignored visual studio.

after adding code web.config, works:

<system.webserver> <handlers>   <!-- following line required correct handling of dots in urls-->   <add name="apiuris-isapi-integrated-4.0"      path="/odata/*"      verb="get,head,post,debug,put,delete,patch,options"      type="system.web.handlers.transferrequesthandler"      precondition="integratedmode,runtimeversionv4.0" />   <!-- end line handling of dots--> </handlers> </system.webserver> 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -