Iv экспериментировал с отличным инструментом, Mvc MiniProfiler.
Я не хочу замаскировать все мои представления множеством команд Step
, поэтому я хочу использовать профилировщик при каждом вызове действий. Плохая идея? Это то, что я пробовал до сих пор:
public abstract class BaseController : Controller
{
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
var profiler = MiniProfiler.Current;
using (profiler.Step("Action: "+filterContext.ActionDescriptor.ActionName))
{
base.OnActionExecuting(filterContext);
}
}
}
Но я не думаю, что это делает то, что я намереваюсь? Думаю, мне нужно запустить профайлер на OnActionExecuting
и остановить его на OnResultExecuted
. Как это сделать, учитывая, что профилировщик предназначен для использования с инструкцией using
.