I’m learning ASP.net MVC 3 with the music store tutorial–but translating the C# into VB. http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-2
Jon Galloway says that “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”.
I have the following code in my StoreController
Function Details(id As Integer) As String
Return "Store Details, ID= " & i.ToString
End Function
But when I put in the url http://localhost:53867/store/details/5 I get the following server error
The parameters dictionary contains a null entry for parameter ‘i’ of
non-nullable type ‘System.Int32’ for method ‘System.String
Details(Int32)’ in ‘MvcMusicStore.MvcMusicStore.StoreController’. An
optional parameter must be a reference type, a nullable type, or be
declared as an optional parameter. Parameter name: parameters
Based on the Galloway description of default ID paramaters above, I would expect this method to take the 5 that comes at the end of the URL as the (default) parameter. Why is it coming out null? What am I missing?
A few things that I am noticing in your code that you may want to check.