[英]Can POST and GET methods go to different views?
Would it be possible to have my POST method go to a different view to my GET method? 是否可以让我的POST方法转到我的GET方法的不同视图?
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. 在这里,我试图让POST方法弹出一个新的网页/视图。 Differing from the GET method. 与GET方法不同。 This doesn't work because it still expects a view called "Output" 这不起作用,因为它仍然需要一个名为“输出”的视图
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 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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.