From b1390aba96ea436bb0a3327ec167019841ef4495 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Tue, 23 Nov 2021 22:56:17 +1100 Subject: [PATCH] 15.6.1 Using Custom Variables as Action Method Parameters; Listing 15-18. Adding an Action Method Parameter in the HomeController.cs File --- UrlsAndRoutes/UrlsAndRoutes/Controllers/HomeController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UrlsAndRoutes/UrlsAndRoutes/Controllers/HomeController.cs b/UrlsAndRoutes/UrlsAndRoutes/Controllers/HomeController.cs index 3de72d8..819fed0 100644 --- a/UrlsAndRoutes/UrlsAndRoutes/Controllers/HomeController.cs +++ b/UrlsAndRoutes/UrlsAndRoutes/Controllers/HomeController.cs @@ -16,11 +16,11 @@ namespace UrlsAndRoutes.Controllers return View("ActionName"); } - public ActionResult CustomVariable() + public ActionResult CustomVariable(string id) { ViewBag.Controller = "Home"; ViewBag.Action = "CustomVariable"; - ViewBag.CustomVariable = RouteData.Values["id"]; + ViewBag.CustomVariable = id; return View(); } }