I am struggling to call an action in a View to another View actioncontroller by passing to it a parameter.
This is the call from the View (I am in the index View and call the Account controller):
@Html.ActionLink("parameters", "MyParameters", "Account", new { email = "test" })
My runtime compiler is saying “cannot resolve action MyParameters” what’ s wrong with it ?
This is the function from my account controller:
public ActionResult MyParameters(string email) {}
This is my route:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Paramètres par défaut
);
}
Cheers
Try:
The overload is:
routeValuesis for adding a query string on the link. So for example, if you wanted to add id=1 to the link, your action link would look like this:this would produce the following:
if you want email as a querystring you need to do this:
this will produce: