Dear All,
We are facing error while hitting the url. Code is given below:
using ODataMovies.Models; using System.Web.Http; using System.Web.OData.Builder; using System.Web.OData.Extensions; using ODataMovies.Models.Dsp; namespace ODataMovies { public static class WebApiConfig { public static void Register(HttpConfiguration config) { config.MapHttpAttributeRoutes(); ODataConventionModelBuilder modelBuilder = new ODataConventionModelBuilder(); modelBuilder.EntitySet<Movie>("Movies"); modelBuilder.EntitySet<Job>("Defaults"); config.MapODataServiceRoute("Movies", "odata", modelBuilder.GetEdmModel()); } } }
If we hit the url like http://localhost:32097/odata/Movies . it will return data successfully.
If we hit the url like http://localhost:32097/odata/Defaults . it return error like
{"error": {"code": "","message": "No HTTP resource was found that matches the request URI 'http://localhost:32097/odata/Defaults'.","innererror": {"message": "No routing convention was found to select an action for the OData path with template '~/entityset'.","type": "","stacktrace": "" } } }
Movie Controller Code:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using ODataMovies.Models; using ODataMovies.Business; using System.Web.OData; using System.Web.Http; using System.Net; using System.Diagnostics; using ODataMovies.Models.Dsp; namespace ODataMovies.Controllers { public class MoviesController : ODataController { [EnableQuery] public IList<Movie> Get() { return m_service.Movies; } } }
Defaults Controller:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using ODataMovies.Models; using ODataMovies.Business; using System.Web.OData; using System.Web.Http; using System.Net; using System.Diagnostics; using ODataMovies.Models.Dsp; namespace ODataMovies.Controllers { public class DefaultsController : ODataController { [EnableQuery] public IList<Movie> Get() { return m_service.Movies; } } }
I think, the issue is with multiple controller registration with odata in webapiconfig.cs.
I am not sure how configure multiple controller with odata in webapiconfig.cs