Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would rather use <strong>MVC Filters</strong> for profiling since MVC Filters allow to add pre- and post-processing behaviours and <em>filterContext</em> parameter should give you enough information. </p> <p>For example, I would create ProfilerAttribute for profiling </p> <pre><code>public class ProfilerAttribute : FilterAttribute, IActionFilter, IResultFilter, IExceptionFilter { public void OnActionExecuting(ActionExecutingContext filterContext) { Debug.WriteLine("Before Action is executing"); } public void OnActionExecuted(ActionExecutedContext filterContext) { Debug.WriteLine("After Action is executed"); } public void OnResultExecuted(ResultExecutedContext filterContext) { Debug.WriteLine("After Action Result is executed"); } public void OnResultExecuting(ResultExecutingContext filterContext) { Debug.WriteLine("Before Action Result is executing"); } public void OnException(ExceptionContext filterContext) { Debug.WriteLine("oops! exception"); } } </code></pre> <p>and register as <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.globalfilters.filters%28v=VS.98%29.aspx" rel="nofollow">GlobalFilter</a> in <strong>Global.ascx</strong>....</p> <pre><code>public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); filters.Add(new ProfilerAttribute()); } </code></pre> <p>Hope it can help. Thanks. </p> <p><strong>update</strong>: Forgot to mention that the MVC Filter only executed <em>after</em> the routing is matched. So, you don't need to filter out for static resources since it was already done by MVC.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload