【发布时间】:2012-07-14 00:35:12
【问题描述】:
以下是提交数据的控制器的两个示例。如果验证失败,一个返回输入模型,另一个则没有。有人能告诉我哪种方法是正确的还是首选的?它们的行为似乎完全相同。
返回模型
[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();
}
【问题讨论】:
标签: c# asp.net asp.net-mvc asp.net-mvc-3 validation