From a2dc13847aeb685301f6be6f0f1a275c13c88074 Mon Sep 17 00:00:00 2001 From: gorohoroh Date: Thu, 5 Jul 2018 17:48:29 +0300 Subject: [PATCH] Adding a redirect to action to prevent duplicate POST requests (with two different kinds of syntax) --- OdeToFoodRider/OdeToFoodRider/Controllers/HomeController.cs | 2 +- .../OdeToFoodVisualStudio/Controllers/HomeController.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OdeToFoodRider/OdeToFoodRider/Controllers/HomeController.cs b/OdeToFoodRider/OdeToFoodRider/Controllers/HomeController.cs index 0aeaa02..32e76e0 100644 --- a/OdeToFoodRider/OdeToFoodRider/Controllers/HomeController.cs +++ b/OdeToFoodRider/OdeToFoodRider/Controllers/HomeController.cs @@ -56,7 +56,7 @@ public IActionResult Create(RestaurantEditModel model) newRestaurant = _restaurantData.Add(newRestaurant); - return View("Details", newRestaurant); + return RedirectToAction("Details", new {id = newRestaurant.Id}); } } } \ No newline at end of file diff --git a/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Controllers/HomeController.cs b/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Controllers/HomeController.cs index 3444943..ea08154 100644 --- a/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Controllers/HomeController.cs +++ b/OdeToFoodVisualStudio/OdeToFoodVisualStudio/Controllers/HomeController.cs @@ -60,7 +60,7 @@ public IActionResult Create(RestaurantEditModel model) newRestaurant = _restaurantData.Add(newRestaurant); - return View("Details", newRestaurant); + return RedirectToAction(nameof(Details), new { id=newRestaurant.Id }); } }