mvc two areas with same name in different project

384 Views Asked by At

I have a project with the following structure:

Solution
- CMS.core
---Areas
------Admin
---------Controllers
- Site.Web
---Areas
------Admin
---------Controllers

Everytime I try to route to a controller under site.web/areas/admin/controllers it appears to only look in cms.core/areas/admin/controllers.

Does this make sense? How do I route mvc to multiple areas of the same name located in different projects?

1

There are 1 best solutions below

2
On

You need to provide the namespace in which the controller resides.. for example:

routes.MapRoute(
    "SiteWebAdminRoute",
    "site.web/areas/{controller}/{action}/{id}", 
    new { Area = "SiteWeb", controller = "Home", action = "Index", id = UrlParameter.Optional },
    new string[] { "Site.Web.Areas.Admin.Controllers" });

..or something similar. Notice the string array down the bottom though. If you look in the Intellisense, it shows you that this string array represents any namespaces where this route should look for controllers. You can do the same with your other area route.. except you would provide a different namespace to look in.