1.从NuGet上下载所需要的包:MiniProfiler.mvc,MiniProfiler,MiniProfiler.ef
2.Global.asax 加入
protected void Application_Start()
{
MiniProfiler.Settings.Results_Authorize = Request =>
{
#if DEBUG
return true;
#else
return false;
#endif
};
StackExchange.Profiling.EntityFramework6.MiniProfilerEF6.Initialize();
}
protected void Application_BeginRequest()
{
if (Request.IsLocal)//这里是允许本地访问启动监控,可不写
· {
MiniProfiler.Start();
}
}
protected void Application_EndRequest()
{
MiniProfiler.Stop();
}
3.在模板页中修改
<head>
@using StackExchange.Profiling;
</head>
<body>
@RenderBody()
@MiniProfiler.RenderIncludes()
</body>
4. web.config 加入 system.webServer节点
<system.webServer>
<handlers>
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>