Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC return Index view after httpPost

I have created a two views in same controller. the issue is, i want to load second view after httppost is done.

Index View

public ActionResult Index()
{
  return View();
}

HttpPost

[HttpPost]
public ActionResult Index(AccountModel model)
{

  return View("NEXTVIEW");

}

Next View

public ActionResult NEXTVIEW(EpmloyeeModal model)
{
  return View();
}

After HttpPost, I have added return to nextview. whereas it always return back to Index view. I tried to find such scenario on different websites, but could not find anywhere.

Thanks.

like image 532
Aqdas Avatar asked Feb 19 '14 11:02

Aqdas


2 Answers

Try like this

[HttpPost]
public ActionResult Index(AccountModel model)
{
  return RedirectToAction("NEXTVIEW");
}
like image 64
Nilesh Gajare Avatar answered Oct 05 '22 06:10

Nilesh Gajare


For post action, use this:

[HttpPost]
public ActionResult Index(AccountModel model)
{
   return RedirectToAction("NEXTVIEW");
}
like image 43
Jeyhun Rahimov Avatar answered Oct 05 '22 07:10

Jeyhun Rahimov