1

I can not figure this out.

How to solve the problem?

AdminAreaReistration cs

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

RouteConfig

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

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Default", action = "Index", id = UrlParameter.Optional }
        );
    }

enter image description here

Oğuzhan Sari
  • 89
  • 1
  • 9
  • How is the error being generated? Are you attempting to go to a particular URL or are you trying to generate a URL with something like `Url.Action`? – Chris Pratt Nov 17 '16 at 18:23

1 Answers1

2

According to error image, you may use different namespaces when declaring an area into RegisterArea to avoid naming conflict between default route and area route:

AdminAreaRegistration.cs

public override void RegisterArea(AreaRegistrationContext context) 
{
    context.MapRoute(
        "CMSAdmin_default",
        "CMSAdmin/{controller}/{action}/{id}",
        new { action = "Index", id = UrlParameter.Optional },
        new[] { "cms.site.Areas.CMSAdmin.Controllers" } // Insert area namespace here
    );
}

RouteConfig.cs

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

    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Default", action = "Index", id = UrlParameter.Optional },
        namespaces: new[] { "cms.site.Controllers" } // Insert project namespace here
    );
}

Possible causes from Multiple types were found that match the controller name error:

1) Using same controller name with different areas (this is likely your current issue),

2) Renaming project namespace/assembly name (delete old project name DLL file inside /bin directory then clean and rebuild again),

3) Conflict between references with same name but different versions (remove older reference then refactor).

References:

Multiple types were found that match the controller named 'Home'

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

Community
  • 1
  • 1
Tetsuya Yamamoto
  • 24,297
  • 8
  • 39
  • 61