首页 > 代码库 > MiniProfiler

MiniProfiler

1.安装MiniProfiler包

PM> Install-Package MiniProfiler

2.在Views下的web.config中引入命名空间:

    <pages pageBaseType="System.Web.Mvc.WebViewPage">      <namespaces>        <add namespace="StackExchange.Profiling" />        ......      </namespaces>    </pages>

3.在_Layout</body>前加入:

@MiniProfiler.RenderIncludes();

4.在Global.asax中加入:

protected void Application_BeginRequest(){    if (Request.IsLocal) { MiniProfiler.Start(); } //or any number of other checks, up to you}protected void Application_EndRequest(){    MiniProfiler.Stop(); //stop as early as you can, even earlier with MvcMiniProfiler.MiniProfiler.Stop(discardResults: true);}

5.在web.config中加入(如果MiniProfiler不展示任何信息):

<system.webServer>  ...  <handlers>    <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />  </handlers></system.webServer>

demo

MiniProfiler