【问题标题】:Set form post timeout设置表单发布超时
【发布时间】:2015-09-15 15:21:54
【问题描述】:

我有一个上传文件的表单,服务器必须处理需要几分钟的大型操作。

我的代码:

.cshtml:

@using (Html.BeginForm("MyAction", "MyController", FormMethod.Post,
            new { enctype = "multipart/form-data" }))
{
    <input type="file" name="file"/>
    <input type="submit" value="submit" />
}

控制器:

[HttpPost]
public ActionResult MyAction(HttpPostedFileBase file)
{
    // Process a large operation here.

    return View();
}

我知道web.config configurationserver code 可以做到这一点。
我的问题:是否有可能与客户端配置有关?

我问是因为当使用XMLHttpRequestjQuery.ajax 时可以设置超时,所以可以在html 表单标签或其他东西中做吗?

【问题讨论】:

标签: c# asp.net-mvc asp.net-mvc-4


【解决方案1】:

其中一个选项是创建 AsyncController,然后您可以在操作中设置 [AsyncTimeout(xxxx)] 或 [NoAsyncTimeout] 属性。

Here is an example on how to do it

【讨论】:

  • 感谢您的回答,但我正在尝试将客户端配置为 jQuery.ajax。 +1。
  • @JonnyPiazzi 那么您可以考虑在您可以指定超时的视图中使用 jQuery.ajax。但我建议使用 AsyncController
猜你喜欢
  • 2011-05-06
  • 2023-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多