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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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>
Method 2
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..
}
Method 3
If the action is in the default controller then home/upload does not work, you just put the action name.
Method 4
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
Method 5
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/
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0