15.6.1 Using Custom Variables as Action Method Parameters; Listing 15-18. Adding an Action Method Parameter in the HomeController.cs File

chap15
Jason Zhu 2021-11-23 22:56:17 +11:00
parent 0f14a97ae2
commit b1390aba96
1 changed files with 2 additions and 2 deletions

View File

@ -16,11 +16,11 @@ namespace UrlsAndRoutes.Controllers
return View("ActionName"); return View("ActionName");
} }
public ActionResult CustomVariable() public ActionResult CustomVariable(string id)
{ {
ViewBag.Controller = "Home"; ViewBag.Controller = "Home";
ViewBag.Action = "CustomVariable"; ViewBag.Action = "CustomVariable";
ViewBag.CustomVariable = RouteData.Values["id"]; ViewBag.CustomVariable = id;
return View(); return View();
} }
} }