6

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.

4 Answers 4

19

Try like this

[HttpPost]
public ActionResult Index(AccountModel model)
{
  return RedirectToAction("NEXTVIEW");
}
Sign up to request clarification or add additional context in comments.

Comments

5

For post action, use this:

[HttpPost]
public ActionResult Index(AccountModel model)
{
   return RedirectToAction("NEXTVIEW");
}

1 Comment

Oh, I was late for answer ;(
5

Your next view action is expecting a model, you need to pass it the EpmloyeeModal model

[HttpPost]
public ActionResult Index(AccountModel model)
{
  return RedirectToAction("NEXTVIEW",new EpmloyeeModal());
}

Comments

4

For Post Use, the following:

[HttpPost]
public ActionResult Index(AccountModel model)
{
   return RedirectToAction("NEXTVIEW"); // Redirect to your NextView
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.