ASP.NET MVC 2 Preview 2: Areas duplicate controller problem

前端 未结 2 1072
旧巷少年郎
旧巷少年郎 2021-02-09 21:44

I am continuing to enslave the MVC 2 thing: Areas...

Now I have two controllers with the same name (HomeController) in the main Controllers folder and in one of the Area

2条回答
  •  我在风中等你
    2021-02-09 22:08

    If you create application namespace is MvcApplication1, you wrote try this.

    public static void RegisterRoutes(RouteCollection routes)
    {
      routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
      AreaRegistration.RegisterAllAreas();
      routes.MapRoute(
        "Default",                                              // Route name
        "{controller}/{action}/{id}",                           // URL with parameters
        new { controller = "Home", action = "Index", id = "" }, // Parameter defaults
        null,
        new[] { "MvcApplication1.Controllers" }
      );
    
    }
    

    Set root route controller namespace "MvcApplication1.Controllers", it running.

    Hope this tips.

提交回复
热议问题