The error message "No non-OData HTTP route registered" typically indicates that there is a problem with the routing configuration of your ASP.NET Web API OData service.
By default, ASP.NET Web API OData routes all requests through the OData routing engine. This means that any requests that do not match an OData route will result in a 404 Not Found error. If you want to handle non-OData requests, you need to add a catch-all route that will handle any requests that do not match an OData route.
Here is an example of how to configure a catch-all route in your ASP.NET Web API OData service:
csharpconfig.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "Default",
routeTemplate: "{*url}",
defaults: new { controller = "NotFound", action = "Index" }
);
In the above example, we are first calling MapHttpAttributeRoutes
to register any attribute-based routes, and then adding a catch-all route that maps to the NotFoundController
with the Index
action. The {*url}
placeholder captures any URL segments that do not match an existing route, allowing the catch-all route to handle these requests.
You can modify the defaults
parameter to map to a different controller and action if needed.
Make sure to add this configuration before any OData route configuration, so that non-OData requests can be handled before being checked against OData routes.
Comments
Post a Comment