Permalink
Browse files

updated stopwatch attribute to per request storage

  • Loading branch information...
1 parent d771ea8 commit 06b2e3062befbeab69e6d2b16b9120b3cc086c7b @nberardi nberardi committed May 2, 2011
Showing with 6 additions and 9 deletions.
  1. +6 −9 src/Web/Mvc/StopwatchAttribute.cs
@@ -6,21 +6,18 @@ namespace ManagedFusion.Web.Mvc
{
public class StopwatchAttribute : ActionFilterAttribute
{
- private Stopwatch _stopwatch;
-
- public StopwatchAttribute()
- {
- _stopwatch = new Stopwatch();
- }
-
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
- _stopwatch.Start();
+ var stopwatch = new Stopwatch();
+ filterContext.HttpContext.Items["Stopwatch"] = stopwatch;
+
+ stopwatch.Start();
}
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
- _stopwatch.Stop();
+ var stopwatch = (Stopwatch)filterContext.HttpContext.Items["Stopwatch"];
+ stopwatch.Stop();
var httpContext = filterContext.HttpContext;
var response = httpContext.Response;

0 comments on commit 06b2e30

Please sign in to comment.