I have this Action in the controller MattinaleController:
public ActionResult Modifica(int id)
{
// manipulate data from repository
return RedirectToAction("Modifica", "Modifica");
}
and this is my routing:
routes.MapRoute(
name: "",
url: "",
defaults: new { controller = "Mattinale", action = "Index" }
);
routes.MapRoute(
name: "",
url: "ModificaComunicazione/{IDArticolazione}",
defaults: new { controller = "Mattinale", action = "Modifica" }
);
routes.MapRoute(
name: "",
url: "{anno}/{mese}/{giorno}",
defaults: new { controller = "Mattinale", action = "Index" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
When I start debugging and try to call the route myHost/ModificaComunicazione/5
(random number here), I get this error (translated):
Parameters dictionary contains Null value for parameter 'id' of non nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Modifica(Int32)' in 'Mattinale.WebUI.Controllers.MattinaleController'
Looks like it doesn't take the parameter. What am I missing?!
Thanks, Davide.