I’ve been following the excellent MVC Music Store tutorial over at ASP.NET. All was going well until I ran into this unhandled exception:
A route named ‘Default’ is already in the route collection. Route names must be unique. Parameter name: name
The following piece of code is highlighted when the exception is thrown:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
I hadn’t modified the above piece of code at all. The only change I made to the global file was to include some code in Applicatio_Start that tells the Entity Framework about .cs class that contains sample data.
I’m at a loss as to why this is happening, and, as I’m doing a tutorial, MVC is obviously new to me. Would be much appreciated if someone could resolve the issue.
You are probably calling
RegisterRoutestwice inApplication_Start.