15.6.2.1 Using Optional URL Segments to Enforce Separation of Concerns; Listing 15-21. Defining a Default Value for an Action Method Parameter in the HomeController.cs File
parent
ed932d419f
commit
e738287bc2
|
@ -16,11 +16,11 @@ namespace UrlsAndRoutes.Controllers
|
|||
return View("ActionName");
|
||||
}
|
||||
|
||||
public ActionResult CustomVariable(string id)
|
||||
public ActionResult CustomVariable(string id = "DefaultId")
|
||||
{
|
||||
ViewBag.Controller = "Home";
|
||||
ViewBag.Action = "CustomVariable";
|
||||
ViewBag.CustomVariable = id ?? "<no value>";
|
||||
ViewBag.CustomVariable = id;
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue