Reputation: 2026
Would it be possible to have my POST method go to a different view to my GET method?
Example:
[HttpGet]
public ActionResult Output()
{
var model = new VTOutputModel();
return View(model);
}
[HttpPost]
public PartialViewResult OutputPartialView(VTOutputModel model)
{
return PartialView(model);
}
Here I attempted to have the POST method pop up with a new webpage/view. Differing from the GET method. This doesn't work because it still expects a view called "Output"
Upvotes: 2
Views: 309
Reputation: 5637
You can specify the name of the view you want to return by doing:
return View("OutputPost", model);
http://msdn.microsoft.com/en-us/library/dd460310(v=vs.98).aspx
As a full example:
[HttpGet]
public ActionResult Output()
{
var model = new VTOutputModel();
return View(model);
}
[HttpPost]
public ActionResult Output(VTOutputModel model)
{
return PartialView("OutputPost", model);
}
Upvotes: 4