以下是提交数据的控制器的两个示例。如果验证失败,一个返回输入模型,另一个则没有。有人能告诉我哪种方法是正确的还是首选的?它们的行为似乎完全相同。
带返回模型
[HttpPost]
public ActionResult Register(RegisterModel model)
{
if (ModelState.IsValid)
{
//do stuff
}
return View(model);
}
不返回模型
[HttpPost]
public ActionResult Register(RegisterModel model)
{
if (ModelState.IsValid)
{
//do stuff
}
return View();
}