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}"
);
}
}
}