title: ASP NET MVC Area routing/multiple routes issue in VB
body: <p>I'm pretty inexperienced with .net and have just started learning MVC.  I've hit an issue concerning multiple controllers being found:</p>
  
  <p><em>"Multiple types were found that match the controller named 'reviews'. 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."</em></p>
  
  <p>I've recently added a new "Admin" area to my app and within that I have a "ReviewController".  There is also a "ReviewController" within the main app folder:</p>
  
  <p>ah - as a new user I can't post an image, but basically I have a "ReviewController" in "Controllers" and in "Areas/Admin/Contollers".</p>
  
  <p>I have 2 routes set up so far:</p>
  
  <p><strong>Default route in Global.asax.vb</strong></p>
  
  <pre><code>  Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
  
       ' MapRoute takes the following parameters, in order: 
       ' (1) Route name
       ' (2) URL with parameters
       ' (3) Parameter defaults
  
       routes.MapRoute( _
         "Default", _
         "{controller}/{action}/{id}", _
         New With {.controller = "Home", .action = "Index", .id = UrlParameter.Optional}, _
         {"PowellCasting/Controllers"}
       )
  
    End Sub
  
    Sub Application_Start()
  
      AreaRegistration.RegisterAllAreas()
  
      System.Data.Entity.Database.SetInitializer(New System.Data.Entity.DropCreateDatabaseIfModelChanges(Of Models.PowellCastingEntites))
      Database.SetInitializer(Of PowellCastingEntites)(New PowellCastingInitializer())
  
      RegisterGlobalFilters(GlobalFilters.Filters)
      RegisterRoutes(RouteTable.Routes)
  
      ControllerBuilder.Current.DefaultNamespaces.Add("PowellCasting/Controllers")
  
    End Sub
  </code></pre>
  
  <p><strong>Area route in AdminAreaRegistration</strong></p>
  
  <pre><code>Namespace PowellCasting.Areas.Admin
    Public Class AdminAreaRegistration
      Inherits AreaRegistration
  
      Public Overrides ReadOnly Property AreaName() As String
        Get
          Return "Admin"
        End Get
      End Property
  
      Public Overrides Sub RegisterArea(ByVal context As System.Web.Mvc.AreaRegistrationContext)
        context.MapRoute( _
          "Admin_default", _
          "Admin/{controller}/{action}/{id}", _
           New With {.Controller = "Dashboard", .action = "Index", .id = UrlParameter.Optional}
         )
      End Sub
    End Class
  End Namespace
  </code></pre>
  
  <p>After reading around the issues I was having, I have added a number of bits of code:</p>
  
  <p>My Admin controllers have the right namespace defined </p>
  
  <ul>
  <li>Namespace PowellCasting.Areas.Admin rather than simply PowellCasting.  </li>
  <li>I have RegisterAllAreas set in the global</li>
  <li>ControllerBuilder.Current.DefaultNamespaces.Add("PowellCasting/Controllers") is in place to specify the default route.</li>
  </ul>
  
  <p>The specific problem I have now is that when I go to "/Reviews" I get the multiple controllers error shown above, specifically:</p>
  
  <p>*The request for 'reviews' has found the following matching controllers:
  PowellCasting.PowellCasting.Areas.Admin.ReviewsController</p>
  
  <p>PowellCasting.PowellCasting.ReviewsController*</p>
  
  <p>I've enabled the route debugger and that only shows one match:</p>
  
  <p>ah - as a new user I can't post an image but it shows:</p>
  
  <p>Admin/{controller}/{action}/{id} as FALSE</p>
  
  <p>and</p>
  
  <p>{controller}/{action}/{id} as TRUE</p>
  
  <p>This is as expected so I don't know why I'm receiving the issue.</p>
  
  <p>I have read about overloading the maproute method with the namespace, but couldn't find an example in VB (loads in c#).  But I tried this:</p>
  
  <pre><code>Public Overrides Sub RegisterArea(ByVal context As System.Web.Mvc.AreaRegistrationContext)
    context.MapRoute( _
        "Admin_default", _
       "Admin/{controller}/{action}/{id}", _
        New With {.Controller = "Dashboard", .action = "Index", .id = UrlParameter.Optional}, _
        vbNull,
        {"PowellCasting/Areas/Admin/Controllers"}
    )
  End Sub
  </code></pre>
  
  <p>and </p>
  
  <pre><code>Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
  routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
  
  ' MapRoute takes the following parameters, in order: 
  ' (1) Route name
  ' (2) URL with parameters
  ' (3) Parameter defaults
  
  routes.MapRoute( _
      "Default", _
      "{controller}/{action}/{id}", _
      New With {.controller = "Home", .action = "Index", .id = UrlParameter.Optional}, _
      vbNull,
      {"PowellCasting/Controllers"}
  )
  
  End Sub
  </code></pre>
  
  <p>but without success.</p>
  
  <p>I'm sure this should be straightforward and I've tried a number of things - it very frustrating.  Any help would be really appreciated.</p>
  
  <p>My first post on here - Hi! :)</p>