Handling Controllers with the Same name

During an upgrade to WebMap it is very common that you might end up with two controllers with the same name in two different namespaces.
Solving that is simple.

For example if we have:

namespace SampleConflictControllers2.Controllers  
{
    public class TestController : Controller
    {
        // GET: Test
        public ActionResult Index()
        {
            return Json("Test from SampleConflictControllers2",JsonRequestBehavior.AllowGet);
        }
    }
}

and

namespace SampleConflictControllers.Controllers  
{
    public class TestController : Controller
    {
        // GET: Test
        public ActionResult Index()
        {
            return Json("Test from SampleConflictControllers",JsonRequestBehavior.AllowGet);
        }
    }
}

If you try to use them you will get an error like:

Multiple types were found that match the controller named 'Test'. 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 'Test' has found the following matching controllers:  
SampleConflictControllers2.Controllers.TestController  
SampleConflictControllers.Controllers.TestController  

Solving that just requires some RouteConfig.cs modifications. You must add the MapRoute calls before any general call.

public static void RegisterRoutes(RouteCollection routes)  
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "ConflictTest",
                url: "SampleConflictControllers2.Controllers/{controller}/{action}/{id}",
                defaults: new { controller = "Test", action = "Index", id = UrlParameter.Optional },
                namespaces: new string[] { "SampleConflictControllers2.Controllers" }
            );

            routes.MapRoute(
              name: "ConflictTest2",
              url: "SampleConflictControllers.Controllers/{controller}/{action}/{id}",
              defaults: new { controller = "Test", action = "Index", id = UrlParameter.Optional },
              namespaces: new string[] { "SampleConflictControllers.Controllers" }
            );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }


            );

        }

In the particular case of webmap you will have to update your ajax calls like:

public label1_Click(e:any) {  
return  window.app.sendAction({mainobj:this,  
controller:"Test",action:"label1_Click"});  
}

To

public label1_Click(e:any) {  
return  window.app.sendAction({mainobj:this,  
controller:"SampleConflictControllers.Controllers/Test",action:"label1_Click"});  
}

or

public label1_Click(e:any) {  
return  window.app.sendAction({mainobj:this,  
controller:"SampleConflictControllers2.Controllers/Test",action:"label1_Click"});  
}