Reputation: 1351
What specifically in WebAPI responds to:
1. http://server/vroot/odata
2. http://server/vroot/odata?$metadata
3. http://server/vroot/odata/Foo
When #3 is requested, I understand that my 'FooController' responds as configured in my WebApiConfig.cs.
But it is not clear to me how WebAPI responds to #1 or #2. How does it know what to return? How is that response configured in my code?
UPDATE: Here is a HUGE clue
One important thing to realize here is that the controller name, the action names, and the parameter names all matter. OData controller and action selection work a little differently than they do in Web API. Instead of being based on route parameters, OData controller and action selection is based on the OData meaning of the request URI. So for example if you made a request for http://my.server.com/vroot/odata/$metadata, the request would actually get dispatched to a separate special controller that returns the metadata document for the OData service. Notice how the controller name also matches the entity set name we defined previously. I’ll try to go into more depth about OData routing in a future blog post. ]
Upvotes: 1
Views: 444
Reputation: 8681
Service Document
Service Metadata Document
WebAPI knows this because you add a route similar to config.Routes.MapODataRoute("ODataRoute", "odata", model);
Check out this detailed explanation: http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/creating-an-odata-endpoint
Upvotes: 2