ASP.NET MVC: post-redirect-get pattern, with only two overloaded action methods
- by Rafi
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.