Fixing the duplicate controller names in ASP.NET MVC

//Edit App_Start > RouteConfig.cs
 public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
 
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                namespaces:  new[] {"ManagementDevelopmentProgram.Controllers"} //add this line
            );
        }
    }
    
 //Edit Areas > YourAreaName > YourAreaNameAreaRegistration.cs
 public override void RegisterArea(AreaRegistrationContext context) 
 {
     context.MapRoute(
         "Admin_default",
         "YourAreaName/{controller}/{action}/{id}",
         new { action = "Index", id = UrlParameter.Optional },
         new[] { "YourAppName.Areas.YourAreaName.Controllers" } //add this line
     );
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s