Search code examples
soapodataasp.net-web-apirestful-authenticationrestful-url

Why doesn't breakpoint run on odata Web api application?


i created Odata service in side of the web api. i put a break point on GetFavoriteStation. but it is not working. mydomain:127.0.0.1

i called this URL : mydomain/odata/2013-06/X(guid’23C868DC-07FE-4AC4-B399-D4E76EDE9F0C’) but it is not working. it returns to me error. ERROR: The resource cannot be found.

  [AllowAnonymous]
public class XController : EntitySetController<X, Guid>
{

    [Queryable]
    public X GetX([FromODataUri]Guid id)
    {
        X x= null;

Look App_Start files

WebApiConfig.cs



namespace Y.Z
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/2013-06/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );


    }


Solution

  • I found that these are suspicious:

    1. The entity set X is not defined in the builder
    2. Maybe should replace config.Routes.MapODataRoute("ODataRoute", "odata/2013-06", model); with config.Routes.MapODataRoute("ODataRoute", "odata-2013-06/*", model);
    3. If it is an odata service there is no need to do this:

      config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/2013-06/{controller}/{id}", defaults: new { id = RouteParameter.Optional } );