.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>監控

相關文章
相關標籤/搜索