Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2012  |  syntax: None  |  size: 1.09 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. .NET Execution Timeout Not Taking Effect in an MVC Web Project
  2. <httpRuntime executionTimeout="5" />
  3.        
  4. <compilation debug="false" targetFramework="4.0">
  5.        
  6. public ActionResult Index()
  7.     {
  8.         Server.ScriptTimeout = 5;
  9.         Thread.Sleep(60 * 1000 * 3);
  10.         return View();
  11.     }
  12.        
  13. System.Web.HttpContext.Current.GetType().GetField("_timeoutState", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(System.Web.HttpContext.Current, 1);
  14.        
  15. public class Timeoutter : ActionFilterAttribute
  16. {
  17.     public override void OnActionExecuting(ActionExecutingContext filterContext)
  18.     {
  19.         System.Web.HttpContext.Current.GetType().GetField("_timeoutState", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(System.Web.HttpContext.Current, 1);
  20.         base.OnActionExecuting(filterContext);
  21.     }
  22. }
  23.        
  24. public static void RegisterGlobalFilters(GlobalFilterCollection filters)
  25.     {
  26.         filters.Add(new Timeoutter());
  27.     }
  28.        
  29. <httpRuntime executionTimeout="5" />
  30. <compilation debug="false" targetFramework="4.0">