I can't seem to figure out how to add a namespace to a custom route I have the following
routes.Add("DomainRoute",
new DomainRoute("{store}.domain.*",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index" },
new string[] { "Mynamespace.Subdomain.Controllers" }));
routes.MapRoute("Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" },
new string[] { "Mynamespace.Controllers" });
Here is the constructor for the DomainRoute
public DomainRoute(string domain, string url, object defaultValues, string[] namespaces)
: base(url, new RouteValueDictionary(defaultValues), new MvcRouteHandler())
{
Domain = domain;
if (namespaces != null && namespaces.Length > 0)
{
DataTokens = new RouteValueDictionary();
DataTokens["Namespaces"] = namespaces;
}
}
But when I run this code I receive the error:
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.