locked
404 when access Breeze controller? RRS feed

  • Question

  • User-1873393951 posted

    I created an Asp.Net MVC 5 project and then used NuGet to add hottowl (which includes Breeze). I have the following controller.

    [BreezeController]
    public class BreezeController : ApiController
    {
        readonly EFContextProvider<ApplicationDbContext> _contextProvider = new EFContextProvider<ApplicationDbContext>();
    
        [HttpGet]
        public string Metadata()
        {
            return _contextProvider.Metadata();
        }
    
        [HttpGet]
        public IQueryable<Event> Events()
        {
            return _contextProvider.Context.Events;
        }
    }

    And the following code exists in file BreezeWebApiConfig.cs. However, I always got the 404 error when try to access http://localhost:49890/Breeze/Events. Did I miss anything? Or is the following breeze routing not working?

    using System.Web.Http;
    
    [assembly: WebActivator.PreApplicationStartMethod(
        typeof(ST13a.App_Start.BreezeWebApiConfig), "RegisterBreezePreStart")]
    namespace ST13a.App_Start {
      ///<summary>
      /// Inserts the Breeze Web API controller route at the front of all Web API routes
      ///</summary>
      ///<remarks>
      /// This class is discovered and run during startup; see
      /// http://blogs.msdn.com/b/davidebb/archive/2010/10/11/light-up-your-nupacks-with-startup-code-and-webactivator.aspx
      ///</remarks>
      public static class BreezeWebApiConfig {
    
        public static void RegisterBreezePreStart() {
          GlobalConfiguration.Configuration.Routes.MapHttpRoute(
              name: "BreezeApi",
              routeTemplate: "breeze/{controller}/{action}"
          );
        }
      }
    }




    Tuesday, November 19, 2013 2:25 AM

Answers

  • User1751268424 posted

    Hi,

    Look at this: routeTemplate: "breeze/{controller}/{action}"

    and your controller name is BreezeController, since: {controller} = Breeze, {action} = Events, then you should call it:

    http://localhost:49890/Breeze/Breeze/Events

    there is no problem with case. You can also call http://localhost:49890/breeze/breeze/events

    Have fun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 19, 2013 9:39 AM