views:

60

answers:

1

I have a site that uses Ninject for dependency injection and I have Routing defined within a Bootstrapper class like so:

    public void RegisterRoutes()
    {
        Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        Routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });

        Routes.MapRoute(
            null,
            "{pageTitle}",
            new { controller = "Home", action = "Page", pageTitle = "Index" }
        );

        Routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

    }

I have added an Area to the project but the default AdminAreaRegistration is not registering the root

    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "Admin_default",
            "Admin/{controller}/{action}/{id}",
            new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }

Where or how do I register the Area with Ninject?

+1  A: 

are you calling RegisterAllAreas()?

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();
    RegisterRoutes(RouteTable.Routes);
}

note it must be called before RegisterRoutes().

dave thieben
@Dave - thanks for your response. I already have this in: protected override void OnApplicationStarted() { AreaRegistration.RegisterAllAreas(); RegisterAllControllersIn(Assembly.GetExecutingAssembly()); var bootstrapper = Kernel.Get<Bootstrapper>(); bootstrapper.RegisterRoutes(); }
Nicholas Murray