Can you guys please check this MapRoute,
routes.MapRoute(
"Topic", // Route name
"{controller}/{action}/{letter}", // URL with parameters
new { controller = "Topic", action = "Letter", letter = UrlParameter.Optional } // Parameter defaults
);
I'm passing an object named "letter". This is a string. The problem that I encountered here is this, when I pass it using the .RouteLink() function
@Html.RouteLink(item, "Topic", new { controller = "Topic", action = "Letter", letter = "A" })
The result is null, for letter.
public ActionResult Letter(string letter)
{
return View();
}
Is there a way wherein I will pass a string type on the MapRoute ? Thanks.
You can do like this
routes.MapRoute(
"Topic", // Route name
"Topic/{entry}", // URL with parameters
new { controller = "Topic", action = "Letter" } // Parameter defaults
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.