ASP.NET MVC and httpRuntime executionTimeout

38.4k Views Asked by At

I would like to increase the httpRuntime executionTimeout for a subsection of an ASP.NET MVC application.

In a regular Web App, you could use:

<configuration>
  <location path="UploadPage.aspx">
    <httpRuntime executionTimeout="600"/>
  </location>
</configuration>

However there really is not the idea of "Folders" in ASP.NET MVC, so how would I go about doing this?

Lets assume the ASP.NET MVC path is /Images/Upload with an ImagesController and Upload Action.

5

There are 5 best solutions below

8
On BEST ANSWER

You can include the whole MVC path (controller and action) in the <location> tag's path attribute. Something like this should work:

<location path="Images/Upload">
    <system.web>
        <httpRuntime executionTimeout="600" />
    </system.web>
</location>
4
On

Chris Hynes solution works! Just be sure to not include ~/ in your path.

This answer details another way - simply set the ScriptTimeout within your action code:

public ActionResult NoTimeout()
{
    HttpContext.Server.ScriptTimeout = 60 * 10; // Ten minutes..
    System.Threading.Thread.Sleep(1000 * 60 * 5); // Five minutes..
    return Content("NoTimeout complete", "text/plain"); // This will return..
}
0
On

If the action is in the default controller then home/upload does not work, you just put the action name.

2
On

Take a look a AsyncController, if you use this, you will have the possibility to set a AsyncTimeout attribute on an action method, so you will be able to timeout a request.

Links that helped me: http://forums.asp.net/p/1564303/3922462.aspx http://dariosantarelli.wordpress.com/2010/10/16/asp-net-mvc-2-handling-timeouts-in-asynchronous-controllers/

0
On

I notice that you are specifically trying to increase the timeout on an upload page. I have had some success with a "chunking" uploader called plupload. A relatively simple MVC actions can be setup to receive the upload's chunks, appending each chunk as it is received. With the small chunks, you will not need to increase the timeout. Of course there might be some browser limitations, but n

http://plupload.com/