I have a route like the following, ideally I would like it to match:
domain.com/layout/1-slug-is-the-name-of-the-page
routes.MapRoute(
"Layout",
"layout/{id}-{slug}",
new { controller = "Home", action = "Index"}, new {id = @"\d+$"}
);
But when I hit the url, I keep getting this exception:
The parameter dictionary contains a null entry for the parameter "id" of a non-zero type, "System.Int32" for the method "System.Web.Mvc.ActionResult Index (Int32)" in ...
The above route will correspond to the following:
domain.com/layout/1-slug or domain.com/layout/1-slug_permalink
It seems that the hyphen that separates the identifier from Slug is causing problems.
source
share