T4MVC and duplicate controller names in different areas
Posted
by artvolk
on Stack Overflow
See other posts from Stack Overflow
or by artvolk
Published on 2010-05-08T13:06:22Z
Indexed on
2010/05/08
13:08 UTC
Read the original article
Hit count: 314
In my application I have controller named Snippets
both in default area (in application root) and in my area called Manage
. I use T4MVC and custom routes, like this:
routes.MapRoute(
"Feed",
"feed/",
MVC.Snippets.Rss()
);
And I get this error:
Multiple types were found that match the controller named 'snippets'. 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 'snippets' has found the following matching controllers: Snippets.Controllers.SnippetsController Snippets.Areas.Manage.Controllers.SnippetsController
I know that there are overloads for MapRoute
that take namespaces
argument, but there are no such overloads with T4MVC support. May be I'm missing something? The possible syntax can be:
routes.MapRoute(
"Feed",
"feed/",
MVC.Snippets.Rss(),
new string[] {"Snippets.Controllers"}
);
or, it seems quite good to me to have namespace as T4MVC property:
routes.MapRoute(
"Feed",
"feed/",
MVC.Snippets.Rss(),
new string[] {MVC.Snippets.Namespace}
);
Thanks in advance!
© Stack Overflow or respective owner