I'm at a loss for why this routing issue is occurring.
Route in Global.asax.cs file:
routes.MapRoute(
"Archives", //Route name
"{controller}/{action}/{month}", // URL with parameters
new { controller = "Articles", action = "Archives" },
new { month = @"^\d+" } // Parameter.defaults
);
Controller:
public ActionResult Archives(int month)
{
ViewData["month"] = month;
return View(article);
}
Which keeps throwing the error:
The parameters dictionary contains a null entry for parameter 'month' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Archives(Int32)' in 'AppleWeb.Controllers.ArticlesController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters
Which is bogus because the URL is: http://localhost:64529/Articles/Archives/12
EDIT- Full routing for all to see:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//routes.IgnoreRoute("tellerSurvey.htm/{*pathInfo}");routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Appleweb", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"Contact", //Route name
"{controller}/{action}/{page}", //URL with parameters
new { controller = "Appleweb", action = "Contact", page = UrlParameter.Optional } // Paramter defaults
);
routes.MapRoute(
"FormDetails", //Route name
"{controller}/{action}/{formid}", // URL with parameters
new { controller = "Resources", action = "FormDetails", formid = 0}
);
routes.MapRoute(
"_calc",
"{controller}/{action}/{calcid}", // URL with parameters
new { controller = "Resources", action = "Calc", calcid = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"Article", //Route name
"{controller}/{action}/{articleid}", // URL with parameters
new { controller = "Articles", action = "Article", id = 0 } // Parameter.defaults
);}
This is an MVC 3 project, so no routingconfig.cs.
new { month = @"^\d+" }?