It looks like you are missing a portion of your route -
http://localhost:49890/breeze/Breeze/Events
Should work
If you want to not be redundant you could either change your prefix ('breeze') or change the controller name ('Breeze')
문제
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}"
);
}
}
}
해결책
It looks like you are missing a portion of your route -
http://localhost:49890/breeze/Breeze/Events
Should work
If you want to not be redundant you could either change your prefix ('breeze') or change the controller name ('Breeze')
다른 팁
Are you using latest breeze? See How will I use breeze with Entity Framework 6 with .net 4.0 which said "You need to install "Breeze Server - for Web API 2" (Breeze.Server.WebApi2).". Try update your hottowel package and try.
As of 11/19/2013, out of the 4 hottowel packages, I only see this one use Breeze.Sever.WebApi2: HotTowel.Angular.Breeze . Maybe the other packages need update to support WebApi2.