Multiple types were found that match the controller named 'Home' - In two different Areas

后端 未结 3 667
情歌与酒
情歌与酒 2021-01-04 05:07

I have two areas in my project. Now when I run the program I get this error:

Multiple types were found that match the controller named \'Home\'. This can h         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-04 05:25

    I don't know what happen, but this code works fine:

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            new string[] { "BaseAdminMVC.Areas.TitomsAdmin.Controllers" }
        );
    }
    

提交回复
热议问题