Kendo.Ui.Core上传异步始终在MVC3应用程序中返回null

时间:2015-02-26 17:35:09

标签: c# jquery asp.net-mvc-3 asynchronous kendo-ui

我正在使用Kendo UI Core脚本,版本2013.2.918在ASP.NET MVC3应用程序中异步上载文件。或者,至少,我正在尝试。

它正确调用了操作,但参数始终为null。这是代码。

<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;
 }

我已经尝试将表单设置为动作,但它仍然做同样的事情。根据KendoUI MVC3约定,我尝试将UploadAwardDocument的参数命名为files,但仍然返回null。

任何误导只是在我连接互联网的笔记本电脑上重新输入代码的问题;除了fiAwardUploader参数为null之外的所有内容都可正常工作。由于遗留编码问题,应用无法在此处发布 - 上传必须是异步的。由于预算限制和我个人的偏好,我们不会转向KendoUI MVC3专业套件。

我被困住了,距离必须放弃KendoUI解决方案并找到另一个异步上传工具正好16个小时。

1 个答案:

答案 0 :(得分:2)

想出来。 <input id="fiAwardUploader" type="file"/>也需要设置名称。 <input id="fiAwardUploader" name='fiAwardUploader' type="file"/>有效。

这在KendoUI文档中没有明确记录,虽然在MVC3文档中提到过,但在面对这个特定问题时,它并不是一个明显的关联。

正因为如此,我将把问题留在原处,希望能帮到别人。

相关问题