Firstly, I am new to MVC, so please excuse the question if it is basic.
I use a custom route to create the following URL (http: // mysite / subscriber / 12345), where 12345 is the subscriber number. I want him to run the ShowAll action in the Subscriber controller. My route fires and using the Phil debugging debugger, when I pass the above URL, the route debugger shows the ID as 12345.
My controller accepts int as caller id. When it is triggered, the controller generates an error "The parameter dictionary contains a null entry for the" id "parameter of the non-nullable type" System.Int32 ". Why does the route debugger show the value and the controller does not see it?
Here is my route (the first one is the culprit)
routes.MapRoute(
"SubscriberAll",
"subscriber/{id}",
new { controller = "Subscriber", action = "ShowAll", id=0 },
new { id = @"\d+" }
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Any idea why I am getting null in ShowAll action? Here is the signature of the action method:
public ActionResult ShowAll(int id)
source
share