httpRuntime executionTimeout is not working at all RRS feed

  • Question

  • User974256540 posted

    Hi there.

    We have a WebApi service (which is OData service) and we would like to terminate requests (by IIS) which take too long time.

    (the reason they take long time is bad database query, but that is another story).

    The thing is that no matter what have as "executionTimeout", it doesn't have any effect whatsoever.

    <compilation targetFramework="4.7.2"/>
    <httpRuntime targetFramework="4.7.2" executionTimeout="5" />

    Even if you have a fresh, new WebApi project (create via VS --> new project -> WebApi example) and set the parameter, it will never terminate the request.

    How do we know? , well, for test purposes, we set Thread.Sleep

    // GET api/values/5
    public string Get(int id)

    return "value";

    No matter how long I set the thread sleep, it does not terminate! It can wait for minutes and finally return "value".

    The goal is to terminate requests if they take too much time (let say 20 seconds is a max).

    The compilation "debug" parameter is set to False.

    WebApi is from nuGet v. 5.2.7

    Friday, June 14, 2019 12:38 PM

All replies

  • User1120430333 posted

    Now, you could have a WebAPI setting in front of a WCF Web service with the WebAPI being a WCF client to the WCF Web service. The WCF service timeout default is 5 seconds, and that exception is going to be thrown by the WCF service I guarantee. :)

    Friday, June 14, 2019 3:39 PM
  • User-474980206 posted

    if you run in debug mode, the execution timeout is not honored. 

    Friday, June 14, 2019 3:42 PM