I upgraded to MVC 2, updated all my assemblies (did copy to local also).
I changed my routes to this:
routes.MapRoute(
"Admin",
"admin/{controller}/{action}/{id}",
new { controller = "Admin", action = "index", id = ""},
new[] { "MyNamespace.Web.Controllers.Admin" } // namespace
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" }, // Parameter defaults
new[] { "MyNamespace.Web.Controllers" } // namespace
);
My controllers look like:
/controllers/admin/ProductController.cs
/controllers/ProductController.cs
I am still getting the error:
he controller name 'Product' is ambiguous between the following types:
MyNamespace.Web.Controllers.Admin.ProductController
MyNamespace.Web.Controllers.ProductController
Should adding the namespace fix this issue?
There was a change made to MVC 2 Beta where specifying a namespace (like "MyNamespace.Web.Controllers") would search in that namespace and its child namespaces. This differs from the MVC 1 behavior, where specifying a namespace would cause the factory to look in just that namespace.
This change will be reverted before MVC 2 RTM. Specifically, the MVC 2 RTM behavior will be that specifying "MyNamespace.Web.Controllers" will search just that namespace - just as in MVC 1 - and specifying "MyNamespace.Web.Controllers.*" (note the dot-star) will search that namespace plus its children.
Your first route suggests that there is a class
/controllers/Admin/AdminController.cs
. Is this correct?Also, have a read of this. It looks like you've provided the namespace area, but they don't reside the same structure that seems to be required for ASP.NET MVC v2.
Your project solution structure should look like this:
Your structure appears to look like this.