MiniProfiler使用笔记
安装步骤
- Install-Package MiniProfiler
- Install-Package MiniProfiler.EF6
- Install-Package MiniProfiler.MVC4
后台配置
- 在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>
- 在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();
}
}
前台页面配置
- 页面开始声明引用
@using StackExchange.Profiling;
- 在body标签前添加
@MiniProfiler.RenderIncludes()