1 namespace System.Web.Mvc {
3 using System.Diagnostics.CodeAnalysis;
4 using System.Web.Mvc.Async;
6 [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", Justification = "Unsealed so that subclassed types can set properties in the default constructor.")]
7 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
8 public class AsyncTimeoutAttribute : ActionFilterAttribute {
10 // duration is specified in milliseconds
11 public AsyncTimeoutAttribute(int duration) {
13 throw Error.AsyncCommon_InvalidTimeout("duration");
24 public override void OnActionExecuting(ActionExecutingContext filterContext) {
25 if (filterContext == null) {
26 throw new ArgumentNullException("filterContext");
29 IAsyncManagerContainer container = filterContext.Controller as IAsyncManagerContainer;
30 if (container == null) {
31 throw Error.AsyncCommon_ControllerMustImplementIAsyncManagerContainer(filterContext.Controller.GetType());
34 container.AsyncManager.Timeout = Duration;
36 base.OnActionExecuting(filterContext);