Я пытаюсь реализовать соглашение об отдыхе на своих контроллерах, но не знаю, как справиться с неудачной проверкой модели при отправке ее обратно в представление «Новое» из действия «Создать».
public class MyController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult New()
{
return View();
}
[HttpPost]
public ActionResult Create(MyModel model)
{
if(!ModelState.IsValid)
{
// Want to return view "new" but with existing model
}
// Process my model
return RedirectToAction("Index");
}
}