Is it possible to implement a post-redirect-get pattern with two overloaded action methods (one for a GET action and one for a POST action) in asp.net-mvc .
In all samples of the post-redirect-get MVC template, I saw three different action methods for the post-redirect-get process (corresponding to Initial Get, Post, and Redirection Get), each of which has different names. Is it really necessary to have at least three action methods with different names in asp.net-mvc ?
For example: (Below is the code shown below after the Post-Redirect-Get template?)
public class SomeController : Controller { // GET: /SomeIndex/ [HttpGet] public ActionResult Index(int id) { SomeIndexViewModel vm = new SomeIndexViewModel(id) { myid = id }; //Do some processing here return View(vm); } // POST: /SomeIndex/ [HttpPost] public ActionResult Index(SomeIndexViewModel vm) { bool validationsuccess = false; //validate if (validationsuccess) return RedirectToAction("Index", new {id=1234 }); else return View(vm); } } }
Thank you for your responses.
source share