MVC problems pointing addresses

0

Friends I have the following form that points to a method in my controller CreateFolder I have no problem running my method, however, it is not giving me the view I want ... that is, I I always wait for you to send CreateFolder / index and try to send me to a place that does not exist in my project something like CreateFolder / CreateFolder and it is not what I'm looking for here I leave my code.

[HttpPost]
public ActionResult CreateFolder(FormCollection form) {

  if (micode) {
    //todo mi code bien hermoso

    return View();

  } else {
    //si algo falla
    return View(); //yo quisiera incluso mandar a otra vista si tengo error
    //así si pueden apoyarme con eso estaría genial aunque no es parte mi pregunta

  }

  //end method
}
//no sé porque pero pienso que es algo de este lado
@using (Html.BeginForm("CreateFolder", "CreateFolder", FormMethod.Post, new { enctype = "multipart/form-data", @class = "form-control" })) 
{
<label>Elija un banco:</label> @Html.DropDownList("dropList", new SelectList(new[] { "Bancomer", "Banamex", "Santander", "Banorte" }), new { required = "required" })
<br />
<br />
<label>Agregue un archivo:</label> @Html.TextBox("file", "", new { type = "file", required = "required" })
<br />
<input type="submit" value="cargar" /> }
    
asked by E.Rawrdríguez.Ophanim 17.05.2018 в 21:45
source

2 answers

2

Instead of using one:

return View();

Place the name of the view:

return View("NombreDeLaVista");

To redirect to another action, use RedirectToAction to send to another action.

return RedirectToAction("Index", model);
    
answered by 17.05.2018 / 22:10
source
1

In the MVC you can use:

return View(@Nombre_vista)
return View(@Nombre_vista, @Model)

/// El nombre de método que retornas a la vista,
/// debe de tener el mismo nombre
//  que el nombre del archivo de tu vista
public ActionResult MiMetodo()
{
    return View();
}
    
answered by 17.05.2018 в 22:19