11

I have implemented an ASP.NET http handler. It appears to me that there is no way to set a timeout e.g. if the handler has been running for over X seconds dont serve the result.

Am I correct here or is there a way to achieve a timeout for an ashx handler?

AJM
  • 32,054
  • 48
  • 155
  • 243

1 Answers1

20

ASP.Net has a built in timeout that will cause it to kill a connection exceeding the configured limits.

The default is 110 seconds.

<system.web>
    <httpRuntime executionTimeout="110">        
</system.web>

However, this is disabled when compiled in DEBUG mode.

<!-- Execution Timeout Will Not Be Enforced -->
<compilation debug="true" />

If you need to set an execution timeout for a specific handler, then you can always create a location specifically for that handler, and set the timeout there.

<location path="MyHandler.ashx">
  <system.web>
    <!-- Set execution timeout to 10 minutes -->
    <httpRuntime executionTimeout="600"/>
  </system.web>
</location>
Josh
  • 44,706
  • 7
  • 102
  • 124