ASP.NET MVC: post-redirect-get pattern, with only two overloaded action methods

Posted by Rafi on Stack Overflow See other posts from Stack Overflow or by Rafi
Published on 2012-09-09T11:33:47Z Indexed on 2012/09/09 15:38 UTC
Read the original article Hit count: 264

Is it possible to implement post-redirect-get pattern, with two overloaded action methods(One for GET action and the other for POST action) in ASP.NET MVC.

In all of the MVC post-redirect-get pattern samples, I have seen three different action methods for the post-redirect-get process, each having different names. Is this really required?

For Eg:(Does the code shown below, follows Post-Redirect-Get pattern?)

    public class SalaryTransferController : Controller
            {

            //
            // GET: /SalaryTransfer/
            [HttpGet]
            public ActionResult Index(int id)
            {
                SalaryTransferIndexViewModel vm = new SalaryTransferIndexViewModel(id) { SelectedDivision = DivisionEnum.Contracting };
            //Do some processing here
                return View(vm);
            }

            //
            // POST: /SalaryTransfer/
            [HttpPost]
            public ActionResult Index(SalaryTransferIndexViewModel vm)
            {
                bool validationsuccess = false;
                //validate
                if (validationsuccess)
                    return RedirectToAction("Index", new {id=1234 });
                else
                    return View(vm);
            }
}

Thank you for your responses.

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about mvc