我把它添加到我的Global.asax.cs:
protected void Application_BeginRequest()
{
if (Request.IsLocal)
{
MiniProfiler.Start();
}
}
protected void Application_EndRequest()
{
MiniProfiler.Stop();
}
Run Code Online (Sandbox Code Playgroud)
我补充道
@MiniProfiler.RenderIncludes()
Run Code Online (Sandbox Code Playgroud)
就</body>在_Layout.cshtml 中的标记下方.
在我的控制器中我正在使用:
public class HomeController : Controller
{
public ActionResult Index()
{
var profiler = MiniProfiler.Current; // it's ok if this is null
using (profiler.Step("Set page title"))
{
ViewBag.Title = "Home Page";
}
using (profiler.Step("Doing complex stuff"))
{
using (profiler.Step("Step A"))
{ // something more interesting here
Thread.Sleep(100);
}
using (profiler.Step("Step B"))
{ // and here
Thread.Sleep(250);
} …Run Code Online (Sandbox Code Playgroud)