A route named "x" is already in the route collection. Route names must be unique. Exception with ASP.NET MVC 3

To fix this problem I had to go into the bin folder on my project, delete all DLL files and then rebuild and this fixed the problem.


This error can occur due to multiple causes, I had the same error and solved it by modifying the Global.asax class.

The Application_Start method at Global.asax.cs was like:

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    BundleConfig.RegisterBundles(BundleTable.Bundles);
}

The following line occurs twice in this method:

RouteConfig.RegisterRoutes(RouteTable.Routes);

This ensured that the route was twice added to the route list and at the same time causing the error.

I changed the Application_Start method as follows and the error disappeared:

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    AreaRegistration.RegisterAllAreas();
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    BundleConfig.RegisterBundles(BundleTable.Bundles);
}

This may not be the answer for your problem, but can perhaps help others in the future. I didn't see this answer between the others, so I decided to add this.


I found out that Global.asax was referring to an old version of the site's DLL file before I renamed it. The DLL was not being cleaned up when I did Build > Clean up because the VS project/solution didn't refer to it any more. It seems that sometimes only the newer version of the DLL was being used, allowing the site to work correctly, but eventually both of them would be loaded causing the route conflicts.


The routes get loaded from all assemblies within AppDomain.CurrentDomain, so if your old assemblies are still part of that, you might be still getting old/duplicate routes.


In my case, I faced with this issue, when I added reference to another project from solution, which also was MVC and use the same names in area (I didn't want to added this project, I don't know how it happened). When I removed this DLL, project started to work.