代码之家  ›  专栏  ›  技术社区  ›  Suraj Nair

Kendo MVVM文件上传控制问题

  •  0
  • Suraj Nair  · 技术社区  · 11 年前

    我试图获得与ASP.NET一起工作的Kendo MVVM文件上载。这是我的HTML如何查找上载声明:

    <input name="attachments" 
    id="fileUpload"
    type="file"
    data-role="upload"
    data-async="{ saveUrl: 'FileUpload.aspx', autoUpload: true }"
    data-bind="events: { success: onSuccess,error: onError }">
    

    以及FileUpload页面加载:

    Response.Expires = -1;
    
    //Code to upload -- This returns me the file url that i need to send back as a response
    Response.ContentType = "text/plain";
    Response.Write(fileUrl);
    Response.End();
    

    上面写的页面加载确实按预期运行,并向我返回所需的结果,但这里的kendo控件的行为方式很有趣。它告诉我上传失败,因为错误图标显示在UI上。此外,Kendo提供的错误处理程序被执行,尽管当我尝试访问它时,写入的响应被正确返回:

    e.XMLHttpRequest.responseText
    

    嗯,我想我可能在这里或那里漏掉了什么/犯了一些小错误,但不幸的是,我无法找出同样的问题。有谁可以建议/纠正?

    1 回复  |  直到 11 年前
        1
  •  0
  •   Suraj Nair    11 年前

    文件上传控件的响应似乎应该为空或JSON字符串,否则将被视为错误。我将回复文本更改为:

    Response.Write(new JavaScriptSerializer().Serialize(fileUrl));
    

    解决。

    希望这对其他人有所帮助!