简体   繁体   English

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

[英]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. 我正在使用Kendo UI Core脚本(版本2013.2.918)在ASP.NET MVC3应用程序中异步上传文件。 Or, at least, I'm trying to. 或者,至少,我正在尝试。

It correctly calls the action, but the parameter is always null. 它可以正确调用该动作,但是参数始终为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. 我已经尝试按照KendoUI MVC3约定将UploadAwardDocument的参数命名为files ,但是仍然返回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. 除了fiAwardUploader参数为null以外的所有内容都可以正常工作。 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. 由于预算限制和我的个人喜好,我们将不再使用KendoUI MVC3 Professional Suite。

I'm stuck, and exactly 16 hours from having to ditch the KendoUI solution and find another async upload tool. 我被困住了,距离必须放弃KendoUI解决方案并找到另一个异步上传工具仅16个小时。

Figured it out. 弄清楚了。 <input id="fiAwardUploader" type="file"/> needs to have name set as well. <input id="fiAwardUploader" type="file"/>需要设置名称。 <input id="fiAwardUploader" name='fiAwardUploader' type="file"/> works. <input id="fiAwardUploader" name='fiAwardUploader' type="file"/>起作用。

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. KendoUI文档中没有明确记录该文档,而MVC3文档中对此进行了提及,但面对此特定问题时,显然并没有明显的关联。

Because of that, I'm going to leave the question in place, in the hope that it helps someone else. 因此,我将把问题留在原处,希望它能对其他人有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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