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

后端 未结 3 646
情歌与酒
情歌与酒 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:17

    Right click the project and select clean the project. Or else completely empty the bin directory and then re-build again. This should clear of any left over assemblies

    0 讨论(0)
  • 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" }
        );
    }
    
    0 讨论(0)
  • 2021-01-04 05:26

    I got this error after doing a rename of my project namespace/assembly.

    If you renamed the Namespace/Assembly you might have a leftover assembly/dll from the previous name in your bin folder. Just delete it from there and it should work.

    0 讨论(0)
提交回复
热议问题