Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

480
Vistas
Ajax.BeginForm envía parámetros al controlador

Tengo siguiendo Ajax.BeginForm en la página de visualización

 using (Ajax.BeginForm("Financing_Product_Feature_Upload", "FileUpload", new { productid = @ViewBag.Product_ID }, new AjaxOptions() { HttpMethod = "POST" }, new { enctype = "multipart/form-data"})) { @Html.AntiForgeryToken() <input type="file" name="files"> <input type="submit" value="Upload File to Server"> }

entonces tengo el siguiente método de controlador en la clase de controlador FileUpload

 [HttpPost] public ActionResult Financing_Product_Feature_Upload(HttpPostedFileBase file, string productid) {

pero una vez que hago clic en el botón Enviar anterior, no se dirige al método del controlador Financing_Product_Feature_Upload

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

La serialización de MVC funciona en los atributos de nombre. El nombre del control de formulario debe coincidir con los parámetros de acción del controlador MVC. En su caso, supongo, debería recibir un error en la consola del navegador cuando presiona el botón "Enviar" que dice "no se encontró una acción coincidente en el controlador FileUpload" o algo que le dé ese significado.

 @using (Ajax.BeginForm("Financing_Product_Feature_Upload", "FileUpload", new { productid = @ViewBag.Product_ID }, new AjaxOptions() { HttpMethod = "POST" }, new { enctype = "multipart/form-data" })) { @Html.AntiForgeryToken() <input type="file" name="files"> <input type="submit" value="Upload File to Server"> } public class FileUploadController : Controller { [HttpPost] public ActionResult Financing_Product_Feature_Upload(HttpPostedFileBase files, string productid) { // Action code goes here } }
over 4 years ago · Santiago Trujillo Denunciar

0

intente agregar @ en enctype

 using (Ajax.BeginForm("Financing_Product_Feature_Upload", "FileUpload", new { productid = @ViewBag.Product_ID }, new AjaxOptions() { HttpMethod = "POST" }, new { @enctype = "multipart/form-data"})) { @Html.AntiForgeryToken() <input type="file" name="file"> <input type="submit" value="Upload File to Server"> }
over 4 years ago · Santiago Trujillo Denunciar

0

Agregue @ antes de usar:

 @using (Ajax.BeginForm("Financing_Product_Feature_Upload", "FileUpload", new { productid = ViewBag.Product_ID }, new AjaxOptions() { HttpMethod = "POST" }, new { enctype = "multipart/form-data"})) { @Html.AntiForgeryToken() <input type="file" name="files"> <input type="submit" value="Upload File to Server"> }

Y cambie el nombre del HttpPostedFileBase file a files porque este es el nombre de entrada de su archivo.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda