简体   繁体   中英

Kendo.Ui.Core Upload async always returns null in MVC3 application

I'm using the Kendo UI Core scripts, version 2013.2.918 to upload files asynchronously in an ASP.NET MVC3 application. Or, at least, I'm trying to.

It correctly calls the action, but the parameter is always null. Here's the code.

<form method="post" action="submit">
    <input id="fiAwardUploader" type="file"/>
</form>

$(document.ready(fuction(){
    $('#fiAwardUploader').kendoUpload({
        async:{
            saveUrl: '@(Url.Action("UploadAwardDocument"))',
            autoUpload: false //this is done for testing purposes
        }
     });
 });

 [HttpPost]
 public ActionResult UploadAwardDocument(IEnumerable<HttpPostedFileBase> fiAwardUploader)
 {
     var test = files; //this is always null
     return null;
 }

I've tried setting the form to the action as well, but it still did the same thing. I've tried naming the parameter for UploadAwardDocument to files , per the KendoUI MVC3 convention, but that still returned null.

Any mispellings are simply a problem with having to retype the code on my internet-connected laptop; everything except the fiAwardUploader parameter being null works correctly. Due to legacy coding issues, the app cannot post back here--the upload has to be async. Due to budget constraints and my personal preference, we will not be moving to the KendoUI MVC3 Professional Suite.

I'm stuck, and exactly 16 hours from having to ditch the KendoUI solution and find another async upload tool.

Figured it out. <input id="fiAwardUploader" type="file"/> needs to have name set as well. <input id="fiAwardUploader" name='fiAwardUploader' type="file"/> works.

This is not explicitly documented in the KendoUI documentation, and while it is mentioned in the MVC3 documentation, it's not an obvious association to make when faced with this particular issue.

Because of that, I'm going to leave the question in place, in the hope that it helps someone else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM