首页 > 其他 > 详细

MiniProfiler

时间:2016-09-20 10:19:12      阅读:202      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!