In a view of ClimateChartController I do this code:
@Html.ActionLink("Kies land", "ListCountries", "Continent" new {Selectedyear = @ViewBag.SchoolYear, continentId = @ViewBag.ContinentId})
So this should go to the method ListCountries of ContinentController, along with the given parameters.
Now this doesn't work, if I do it without the parameters it goes to the method but well, I need the parameters...
For now I resolved this by using the following method in ClimateChartController:
public ActionResult ListCountries(int selectedyear, int continentid)
{
return RedirectToAction("ListCountries", "Continent",
new { selectedYear = selectedyear, continentId = continentid });
}
This works as intended, but causes cluttering of code and isn't neat.
So how can I call a method of another controller and pass some parameters with it?