return view with empty model

Asked

Viewed 372 times

3

I do Ubmit to save, and I want it to return in the same view, but with empty fields, a new model, so it can add again

But he always comes back with the data I filled out

My action is like this:

public ActionResult SalvarNovo(grupoViewModel model)
{
  if (ModelState.IsValid)
  {
    Grupo entity = new Grupo();
    Mapper.Map(model, entity);

    grupocService.Adiciona(entity);
  }
  return View("Novo");
}

How do I make it return empty fields? or direct to that view again?

2 answers

3


Assuming that this SalvarNovo is the action of submit of form you simply redirect the user to action that generates the view form.

return RedirectToAction("nome da action que gera o formulario");

2

Use RedirectToAction:

return RedirectToAction("Novo");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.