I have a model like the following:
public class Model_ejemplo
{
public HttpPostedFileBase image { get; set; }
}
in my controller I receive my model with this property
[HttpPost]
public ActionResult index(Model_ejemplo Model)
{
Return view(Model);
}
in my view this is the form where I capture my file
@using (Html.BeginForm("Index", "MyController", FormMethod.Post, new { id = "formulario", enctype = "multipart/form-data" }))
{
@Html.TextBoxFor(x => x.image, new {type= "file", @id = "image", accept ="image/x-png,image/gif,image/jpeg"})
}
The problem is that whenever I return the model in the post action of the controller it arrives as Null in my view, and I need to return this type of data after it has not passed the validations of my action.