Domanda

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?

È stato utile?

Soluzione

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,
...
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top