Question

I'm using async methods in my WebAPi controllers:

public async Task<HttpResponseMessage> SampleMethod(int subscriptionNumber, DateTime departureDate)
{
    // [...]
}

How do I configure the request timeout? The operation can take up to a couple of minutes and I have to make sure that the request do not timeout.

In MVC there is an attribute called [AsyncTimeout]. Are there an equivalent in WebApi? Can it be configured globally?

Was it helpful?

Solution

Good question, I would recommend to handle this from client side - you can always specify timeout settings in your consumer code, even if it is ajax:

$.ajax({
url: "/ajax_json_echo/",
timeout: 1000,
...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top