Part 4 Models and Data Access - unhandled exception been thrown in Global.asax.cs

Oct 24, 2012 at 9:53 PM

I've nearly completed part 4, gotten to the following part


public ActionResult Index()
    var genres = storeDB.Genres.ToList();
    return View(genres);

When I try to run the app, i get the following unhandled exception, can't figure out what's causing it:

A route named 'Default' is already in the route collection. Route names must be unique.
Parameter name: name

Line 23:             routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Line 24: 
Line 25:             routes.MapRoute(
Line 26:                 "Default", // Route name
Line 27:                 "{controller}/{action}/{id}", // URL with parameters

anyone have any ideas on how to resolve? great tutorials otherwise.

Oct 24, 2012 at 9:56 PM

Apologies for the state of the above posting!

Oct 30, 2012 at 8:38 AM

j'ai exactement le même problème. La configuration du serveur peut elle jouer dans ce cas? (Débutant)

I Have the same problem. server configuration can have  role in this case ? (rookie)

Oct 30, 2012 at 12:36 PM

The problem (for me) was caused by calling RegisterRoutes twice in Application_Start in Global.asax.cs.

I typed the code, as it appeared on the tutorial, into Application_Start - without realising that RegisterRoutes was already in there.

Simply remove one of the RegsiterRoutes. It resolved the issue for me.