Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does an ASP.NET HttpHandler ever timeout

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?

like image 247
AJM Avatar asked Apr 27 '12 16:04

AJM


People also ask

What is HTTP handler in ASP.NET MVC?

HTTPHandler is a low level request and response API in ASP.Net for injecting pre-processing logic to the pipeline based on file extensions and verbs. An HTTPhandler may be defined as an end point that is executed in response to a request and is used to handle specific requests based on extensions.

What is the use of HTTPHandlers in web config?

After you have created a custom HTTP handler class, you must register it in the Web. config file. This enables ASP.NET to call the HTTP handler in order to service requests for resources that have the specified file name extension.


Video Answer


1 Answers

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>
like image 130
Josh Avatar answered Sep 20 '22 06:09

Josh