asp.net mvc - MVC C# Controller Conflict (site front with area admin) -
i can not figure out.
how solve 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 } ); }
according error image, may use different namespaces when declaring area registerarea
avoid naming conflict between default route , 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 multiple types found match controller name
error:
1) using same controller name different areas (this current issue),
2) renaming project namespace/assembly name (delete old project name dll file inside /bin directory clean , rebuild again),
3) conflict between references same name different versions (remove older reference refactor).
references:
Comments
Post a Comment