ajax - JQuery Ajax 文件上传大文件失败

标签 ajax asp.net-mvc forms file upload

我目前有一个 ASP.Net MVC Web 应用程序,需要使用 ajax 上传大文件。我目前正在使用这个 jQuery 插件 - http://valums.com/ajax-upload/ .我也用过这个插件 - http://jquery.malsup.com但得到相同的结果。

我对大文件的问题是,为了异步请求而生成的 iframe 没有及时加载。

它似乎总是指向这段代码:
var doc = iframe.contentDocument ? iframe.contentDocument : iframe.contentWindow.document, response;
对于较小的文件,脚本运行良好,但对于较大的文件,iframe 似乎从未正确初始化。

这让我发疯了。有人可以帮忙吗?

提前致谢

最佳答案

您可能需要使用 <httpRuntime> 增加服务器上允许的最大请求大小以及请求的执行超时时间。 web.config 中的部分

<system.web>
    <httpRuntime 
        maxRequestLength="size in kbytes"
        executionTimeout="seconds"
    />

    ...
</system.web>

如果您在 IIS 7.0+ 中部署您的应用程序,您可能还需要使用 <requestLimits> 增加允许的最大请求大小。 <system.webServer>的节点部分:
<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="size in bytes" />
        </requestFiltering>
    </security>

    ...
</system.webServer>

关于ajax - JQuery Ajax 文件上传大文件失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9281933/

相关文章:

javascript - JQuery Ajax PHP 验证注册

jquery - 为什么 Rails 无法从 Internet Explorer 访问 Ajax 请求中的 Session?

forms - 这是 session 范围或请求范围内的 struts 1.x 表单 bean 吗?

forms - 轻松管理 : custom type for a field

javascript - 如何在AJAX成功函数中获取json数据

c# - 如何使用 ASP.NET 和 jQuery 返回 JSON

javascript - 单击按钮时 JS .click() 不起作用

html - 根据 mvc 中的用户名更改按钮文本

asp.net-mvc - MVC 3 - 仅特定用户访问

javascript - 尝试使用 jQuery 的 submitHandler 时表单未提交