Monday, June 6, 2011

Timeouts in Actions of AsyncController

Hi All,

Welcome back to the blog post. Today we will look at the Timeouts in action when using Async actions.

By default an action will be timed out after 45 seconds in Asp.Net mvc, If a method takes more than 45 seconds then it will throw an TimeoutException.
In order to control this behaviour Asp.Net team provide us 2 filters – [AsycnTimeout] and [NoAsyncTimeout].
If you make use of [NoAsyncTimeout] attribute to an action, then TimeoutException will never be thrown from an action.
AsyncTimeout works by taking the expiry time parameter as an input( in Milli seconds), As you know, if the action takes more than the specified time, it throws TimeoutException.

eg:
[AsyncTimeout(50000)] /* Expires after 50 seconds */
public void SampleAsync()
{
}
[NoAsyncTimeout] //Never expires
public void SampleAsync()
{
}

I hope this helps!


Regards,


-Vinayak

No comments: