MvcMusicStore Lesson 2 - How come Internet exception occurrs when Details method input parameter name is changed to idd?

Jun 9, 2012 at 5:58 PM

If I change the StoreController Details method input parameter name from id to idd, as shown below, a browser exception occurs when mapping to Store/Details/5

public string Details(int idd)
   string message = "Store.Details, IDD = " + idd;
    return message;


How come this happens? If the parameter name is id then the mapping works. Why does the parameter have to be named id to work?

Jun 12, 2012 at 7:50 AM

@stevensrf1 The default route in ASP.NET MVC uses a parameter named id. The tutorial explains this in part 2:

ASP.NET MVC lets us easily do this without having to configure anything. ASP.NET MVC’s default routing convention is to treat the segment of a URL after the action method name as a parameter named “ID”. If your action method has a parameter named ID then ASP.NET MVC will automatically pass the URL segment to you as a parameter. 

The default route is defined in global.asax.cs

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