2

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.

Paul
  • 1,457
  • 1
  • 19
  • 36
  • It looks like it's a mirror of my [question](http://stackoverflow.com/questions/22270511/mvc-custom-route-datatokensnamespaces-is-ignored). Have you solved the issue? – Cristian E. Mar 08 '14 at 14:36

0 Answers0