1

I have a form that upload a file and the server has to process a large operation that takes several minutes.

My code:

.cshtml:

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

Controller:

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

    return View();
}

I know it's possible to do it with web.config configuration and with server code.
My question: Is it possible to do with client side configuration?

I ask that because when using XMLHttpRequest like jQuery.ajax its possible to set the timeout, so is it possible to do in html form tag or something?

Community
  • 1
  • 1
Jonny Piazzi
  • 3,684
  • 4
  • 34
  • 81
  • 2
    possible duplicate of [How do I set the request timeout for one controller action in an asp.net mvc application](http://stackoverflow.com/questions/579523/how-do-i-set-the-request-timeout-for-one-controller-action-in-an-asp-net-mvc-app) – musefan Sep 15 '15 at 15:26
  • I update the question. This duplication it's not available anymore. – Jonny Piazzi Sep 15 '15 at 15:32
  • Why is it so important to set it from within your view code? Why can't you modify the controller code? – musefan Sep 15 '15 at 15:42

1 Answers1

2

One of the options is to create AsyncController and then you can set [AsyncTimeout(xxxx)] or [NoAsyncTimeout] attributes in your action.

Here is an example on how to do it

ram hemasri
  • 1,624
  • 11
  • 14
Vlad Bezden
  • 83,883
  • 25
  • 248
  • 179
  • Thanks for the answer, but I'm trying something with client configuration as jQuery.ajax. +1. – Jonny Piazzi Sep 15 '15 at 15:55
  • @JonnyPiazzi then you might consider to use jQuery.ajax from your view where you can specify timeout. But I would recommend to use AsyncController – Vlad Bezden Sep 15 '15 at 16:10