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}"
);
}
}
}
Member
1 Points
66 Posts
404 when access Breeze controller?
Nov 19, 2013 02:25 AM|ydbn|LINK
I created an Asp.Net MVC 5 project and then used NuGet to add hottowl (which includes Breeze). I have the following controller.
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?Contributor
4323 Points
1578 Posts
Re: 404 when access Breeze controller?
Nov 19, 2013 09:39 AM|jsiahaan|LINK
Hi,
Look at this: routeTemplate: "breeze/{controller}/{action}"
and your controller name is BreezeController, since: {controller} = Breeze, {action} = Events, then you should call it:
there is no problem with case. You can also call http://localhost:49890/breeze/breeze/events
Have fun
Indonesian Humanitarian Foundation