MiniProfiler使用笔记

MiniProfiler使用笔记

安装步骤

  1. Install-Package MiniProfiler
  2. Install-Package MiniProfiler.EF6
  3. Install-Package MiniProfiler.MVC4

后台配置

  1. 在Web.Config文件中添加
  <system.webServer>
    <handlers>
      <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
    </handlers>
  </system.webServer>
  <runtime>
  1. 在Global.asax.cs文件中添加和修改
public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            MiniProfilerEF6.Initialize();
        }

        protected void Application_BeginRequest()
        {
            if (Request.IsLocal)
            {
                MiniProfiler.Start();
            }
        }

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

前台页面配置

  1. 页面开始声明引用
@using StackExchange.Profiling;
  1. 在body标签前添加
@MiniProfiler.RenderIncludes()
posted @ 2016-08-14 11:21  柠檬头  阅读(498)  评论(0编辑  收藏  举报