Hi,
I'm having trouble getting a Route working in order to constrain the parameters of an action of a controller to only be integers.
I have a a controller action as follows:
[RequiresRole(RoleToCheckFor = "Administrator"), AcceptVerbs(HttpVerbs.Get)]
public ActionResult Edit(int id)
{
...
}
and the following routes in Global.asax.cs:
routes.MapRoute(
"UserEdit",
"user/edit/{id}",
new {controller = "user", action = "edit"},
new {id = @"\d+"}
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
routes.MapRoute("Error",
"{*url}",
new { controller = "Error", action = "notfound" });
I'm therefore expecting that if i enter http://domain.com/user/edit/ABCD i shouldn't get the following usual error:
The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Edit(Int32)'
This (i think) is precisely what is also said at http://www.asp.net/%28S%28pdfrohu0ajmwt445fanvj2r3%29%29/learn/mvc/tutorial-24-cs.aspx
However, i'm still seeing the "...null entry..." error.
Any ideas why this is so? Am i doing something wrong with the route setup?
Thanks