I tried implementing a Phil Areas Demo demo in my project http://haacked.com/archive/2008/11/04/areas-in-aspnetmvc.aspx . I added the Areas / Blog structure in my existing MVC project and I got the following error in my project.
The controller name "Home" is ambiguous between the following types: WebMVC.Controllers.HomeController WebMVC.Areas.Blogs.Controllers.HomeController
this is what my global.asax looks like.
public static void RegisterRoutes (routes RouteCollection) {routes.IgnoreRoute ("{resource} .axd / {* PathInfo}");
routes.MapAreas("{controller}/{action}/{id}", "WebMVC.Areas.Blogs", new[] { "Blogs", "Forums" }); routes.MapRootArea("{controller}/{action}/{id}", "WebMVC", new { controller = "Home", action = "Index", id = "" }); //routes.MapRoute( // "Default", // Route name // "{controller}/{action}/{id}",// URL with parameters // new { controller = "Home", action = "Index", id = "" } // // Parameter defaults //); } protected void Application_Start() { String assemblyName = Assembly.GetExecutingAssembly().CodeBase; String path = new Uri(assemblyName).LocalPath; Directory.SetCurrentDirectory(Path.GetDirectoryName(path)); ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new AreaViewEngine()); RegisterRoutes(RouteTable.Routes); // RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes); }
If I remove / Areas / Blogs from route.MapAreas, it looks at the root index.
Aarti
source share