.net EF监控 MiniProfiler

1.从NuGet上下载所须要的包:MiniProfiler.mvc,MiniProfiler,MiniProfiler.ef

    

2.Global.asax 加入

protected void Application_Start()
{web

MiniProfiler.Settings.Results_Authorize = Request =>
{
#if DEBUG
  return true;
#else
  return false;
#endif
};mvc


  StackExchange.Profiling.EntityFramework6.MiniProfilerEF6.Initialize();
}
protected void Application_BeginRequest()
{
  if (Request.IsLocal)//这里是容许本地访问启动监控,可不写
·  {
    MiniProfiler.Start();spa

  }
}3d

protected void Application_EndRequest()
{
  MiniProfiler.Stop();
}blog

3.在模板页中修改

<head>ci

    @using StackExchange.Profiling;it

</head>io

<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>监控

相关文章
相关标签/搜索