Note that there are some explanatory texts on larger screens.

plurals
  1. POSame controllername in differents areas
    primarykey
    data
    text
    <p>In a ASP.NET MVC 3 application with areas (see schema below). The "Controllers" directory from the root has been deleted.</p> <p>When I do this : </p> <pre><code> routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); </code></pre> <p>I get this error : <em>Multiple types were found that match the controller named 'Home'. This can happen if the route that services this request ('{controller}/{action}/{id}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter. The request for 'Home' has found the following matching controllers: MyProject.Areas.Administration.Controllers.HomeController MyProject.Areas.BackEnd.Controllers.HomeController MyProject.Areas.FrontEnd.Controllers.HomeController</em></p> <p>When I do this :</p> <pre><code> routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults new string[] { "MyProject.Areas.Administration.Controllers" } ); </code></pre> <p>I get tis error :</p> <pre><code>The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/Home/Index.aspx ~/Views/Home/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx ~/Views/Home/Index.cshtml ~/Views/Home/Index.vbhtml ~/Views/Shared/Index.cshtml ~/Views/Shared/Index.vbhtml ---- Areas | |---- Administration | |--- Controllers | | |---- HomeController | |--- Views | |--- Index |---- FrontEnd | |--- Controllers | | |---- HomeController | |--- Views | |--- Index |---- BackEnd |--- Controllers | |---- HomeController |--- Views |--- Index </code></pre> <p><strong>Update1</strong> To start to a specific controller in the Areas, I tried this :</p> <pre><code>public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional }, new[] { "MyProject.Areas.BackEnd.Controllers" } ); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload