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

Miniprofiler 监控ef执行详解

时间:2016-09-22 11:25:41      阅读:844      评论:0      收藏:0      [点我收藏+]

标签:

首先NuGet添加 相对应ef版本的Miniprofiler.ef引用

技术分享

 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 文件中添加

protected void Application_Start(object sender, EventArgs e)
{

StackExchange.Profiling.EntityFramework6.MiniProfilerEF6.Initialize();

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

在需要监控的webfrom页面中增加

protected override void OnPreRender(EventArgs e)
{
Response.Write(StackExchange.Profiling.MiniProfiler.RenderIncludes());
base.OnPreRender(e);
}

运行页面

技术分享

 

点击share 查看详细信息

技术分享

 

 

以上就是MiniProfiler 监控webfrom中使用ef操作过程。

 

Miniprofiler 监控ef执行详解

标签:

原文地址:http://www.cnblogs.com/farmer-y/p/5895352.html

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