2
On my homepage, there’s a shortcut button that opens a modal, and inside that modal is a partialView which points to a action within another controller. Until then quiet.
<div class="modal fade" id="modalCreate" tabindex="-1" role="dialog" aria-labelledby="createClasseModal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
@Html.Action("Create","Classes")
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
</div>
</div>
</div>
</div>
When opening the modal with the partial view being correctly displayed for inclusion of the information. After inclusion, the routine executes the savechanges
correctly in the controller, then he gives a RedirectToAction
to return to the home screen.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "id,descricao,dia_1,dia_2,horario,dt_inicio,dt_termino,sala,limite_max,limite_min,preco,status,professor")] Classe classe)
{
ViewBag.professor = new SelectList(db.Pessoa, "id", "nome", classe.professor);
if (ModelState.IsValid)
{
db.Classe.Add(classe);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(classe);
}
There in the debug he goes back to the index
, and at the time of redesigning the screen with the modal, it accuses the error:
Does anyone have any idea how to fix this?
Fix, in the controller is
return RedirectToAction("Index");
– Pablo Ramon Borges