title: MVC Custom Route. DataTokens["Namespaces"] is ignored
body: <p>I don't know why while creating a <code>CustomRoute</code> which inherits from <code>Route</code>, the field <code>DataTokens["Namespaces"]</code> is ignored. </p>
  
  <p>And I get the error:
  <em>Multiple types were found that match the controller named 'Home'. This can happen if the route that services this request ('{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.</em>
  Here is the sample:</p>
  
  <p><strong>Application_Start()</strong></p>
  
  <pre><code> public static void RegisterRoutes(RouteCollection routes)
   {
          //Create dataTokens object
          var dataTokens = new RouteValueDictionary();
          var ns = new[] {"MvcDomainRouting.Controllers.Delivery" };
          dataTokens["Namespaces"] = ns;
  
          //Note is a custom route
          routes.Add("DomainRoute", new DomainRoute(
              domain:"delivery.md",                                            // Domain with parameters
              url:"{action}/{id}",                                             // URL with parameters
              defaults: new { controller = "Home", action = "Index", id = "" },// Parameter defaults
              constraints:null,
              dataTokens: dataTokens,
              routeHandler:new MvcRouteHandler()
          ));
  }  
  </code></pre>
  
  <p><strong>DomainRoute.cs</strong></p>
  
  <pre><code>public class DomainRoute : Route
  {
      public string Domain { get; set; }
  
      public DomainRoute(string domain, string url, object defaults, object constraints,object dataTokens, IRouteHandler routeHandler)
          : base(url, new RouteValueDictionary(defaults), new RouteValueDictionary(constraints), new RouteValueDictionary(dataTokens), routeHandler)
      {
          Domain = domain;
      }
  
      public override RouteData GetRouteData(HttpContextBase httpContext)
      {
          //Details ommited
  
          // Route data
          RouteData data = new RouteData(this, RouteHandler);
  
          // 1.Add defaults
          // 2.Map URL key/values
          // Copy the DataTokens from the Route to the RouteData
          if (DataTokens != null)
          {
              foreach (var prop in DataTokens)
              {
                  data.DataTokens[prop.Key] = prop.Value;
              }
          }
  
          return data;
          // At this point `data` holds the DataTokens["Namespaces"] see picture
      }
  
  }
  </code></pre>
  
  <p>The stack trace from <code>return data;</code>:
  <img src="https://i.stack.imgur.com/b6F3r.jpg" alt="enter image description here"></p>
  
  <p><strong>HomeController.cs</strong></p>
  
  <pre><code>namespace MvcDomainRouting.Controllers.Lunch
  {
      [HandleError]
      public class HomeController : Controller
      {
          public ActionResult Index()
          {
              ViewData["Message"] = "Welcome to ASP.NET MVC!";
  
              return View();
          }
  
          public ActionResult About()
          {
              return View();
          }
      }
  }
  
  namespace MvcDomainRouting.Controllers.Delivery
  {
      [HandleError]
      public class HomeController : Controller
      {
          public ActionResult Index()
          {
              return Content("Index din delivery");
          }
  
          public ActionResult About()
          {
              return Content("About din delivery");
          }
      }
  }
  </code></pre>
  
  <h3>Thanks in advance to each who is sharing experience.</h3>
  
  If more details need please ask.