码迷,mamicode.com
首页 > 其他好文 > 详细

MiniProfiler

时间:2016-09-20 10:19:16      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:

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

标签:

原文地址:http://www.cnblogs.com/coce/p/5790443.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!