public IActionResult OnGet(int id) { Restaurant = _restuarantData.Get(id); if (Restaurant == null) { return(RedirectToAction("Index", "Home")); } return(Page()); }
//Having a param on ActionMethod (IActionResult) it'll look for it through the http request, routing and other sources public IActionResult Details(int id) { //Matched in the routing config in startup.cs var model = _resturantData.Get(id); if (model == null) { return(RedirectToAction(nameof(Index))); } return(View(model)); }