您的位置:首页 > 运维架构

EF框架 监控小工具 MiniProfiler

2016-10-14 10:51 417 查看
一、NuGet安装:

MiniProfiler

MiniProfiler.EF6

如果在MVC中使用则再多安装

MiniProfiler.MVC(X) //X:mvc版本号

二、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>


三、Global.asax.cs

protected void Application_Start(object sender, EventArgs e)
{
// 在应用程序启动时运行的代码  ※必须要放置在数据库初始化前
MiniProfilerEF6.Initialize();
// 数据库初始化
Database.SetInitializer<DataBaseCenter.DB.BIContext>(null);

}


protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Request.IsLocal) MiniProfiler.Start();
}


protected void Application_EndRequest()
{
if (Request.IsLocal) MiniProfiler.Stop();
}


页面呈现:在body中添加

<%= Request.IsLocal ? StackExchange.Profiling.MiniProfiler.RenderIncludes().ToString() :"" %>


呈现结果:



这样就可以实地检测喽。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: