How can I return the result of a different action or move the user to a different action if there is an error in my ModelState
without losing my ModelState
information?
The scenario is; Delete
action accepts a POST from a DELETE form rendered by my Index
Action/View. If there is an error in the Delete
I want to move the user back to the Index
Action/View and show the errors that are stored by the Delete
action in the ViewData.ModelState
. How can this be done in ASP.NET MVC?
[AcceptVerbs(HttpVerbs.Post | HttpVerbs.Delete)]
public ActionResult Delete([ModelBinder(typeof(RdfUriBinder))] RdfUri graphUri)
{
if (!ModelState.IsValid)
return Index(); //this needs to be replaced with something that works :)
return RedirectToAction("Index");
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…