Having issue with multiple controllers of the same name in my project

I am running into the following error with my ASP.NET MVC 3 project:

Multiple types were found that match контроллер с именем «Дом». Это может произойдет, если маршрут, обслуживающий это request ('Home / {action} / {id}') делает не указывать пространства имен для поиска контроллер, соответствующий запросу. Если это так, зарегистрируйте это маршрут, вызвав перегрузку Метод MapRoute, который принимает Параметр namespaces.

Запрос на "Home" обнаружил следующие подходящие контроллеры: MyCompany.MyProject.WebMvc.Controllers.HomeController MyCompany.MyProject.WebMvc.Areas.Company.Controllers.HomeController

I have a HomeController in my default controller folder, with a class name of MyCompany.MyProject.WebMvc.Controllers.HomeController.

My RegisterRoutes method, in my global.asax, looks like:

    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 } // Parameter defaults
        );
    }

I then have an area called Company, with a HomeController in the default controller folder for the area, with a class name of MyCompany.MyProject.WebMvc.Areas.Company.Controllers.HomeController.

The RegisterArea method in the CompanyAreaRegistration file looks like:

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

This is all leading the error I highlighted at the beginning of this post. I am struggling trying to piece together a solution from various other posts, with NO LUCK.

Is it possible to have a HomeController in the default controllers folder and then one in EACH area? If so, do I need to make (assuming I do) changes to my configuration file to make this work?

Any help would be much appreciated!

94
задан Dan Atkinson 7 January 2015 в 17:08
поделиться