43

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.

2

5 Answers 5

52

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>
Sign up to request clarification or add additional context in comments.

8 Comments

I'm still having issues making this work... for clarification: the path is relative to the root of the site, or the app? Also, if there are any values being passed in the url would this fail? (ex: Images/Upload/1)
It's relative to the root of the site, but I think you may be out of luck with the additional values on the url. ASP.NET interprets the path strictly and doesn't allow wildcards. 2 ideas: (a) Use QueryString.
(b) Create an actual Images/Upload folder, and put a web.config inside it. Set path="" to apply to the whole folder. Not sure if ASP.NET will interpret this correctly for MVC apps, but it definitely works for normal ASP.NET apps.
please note this is ignored completed if debug mode is on msdn.microsoft.com/en-us/library/vstudio/… executionTimeout Optional Int32 attribute. Specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET. This time-out applies only if the debug attribute in the compilation element is False. Therefore, if the debug attribute is True, you do not have to set this attribute to a large value in order to avoid application shutdown while you are debugging.
Good point. This is a big gotcha because everything works fine in debug mode. Then you go to deploy and it blows up for an unknown reason with poor error messaging.
|
8

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..
}

4 Comments

I don't think the Server.ScriptTimeout way works. I distinctly remember trying that and not getting it to work.
Ah, it was what was checked into our test tier and working before moving back to the web.config version, boss :)
It seems that when using ~/, ASP.NET maps it to a physical path. This doesn't happen when using "controller/action"; it's mapped from the app root. Yeah, don't ask me why - I even dug into Reflector to try and figure it out, but it's a pain following config stuff.
This technique doesn't work for me. I need to set the executionTimeout in web.config instead.
1

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

Comments

1

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/

2 Comments

This won't Increase the timeout as the OP wanted. The runtime will timeout before the async timeout happens.
Now a broken link
1

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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.