Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

479
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!