性能工具MiniProfiler在Asp.Net WebForm跟踪EntityFramework

Posted 吴晓阳

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了性能工具MiniProfiler在Asp.Net WebForm跟踪EntityFramework相关的知识,希望对你有一定的参考价值。

http://www.xuebuyuan.com/356638.html

选择MiniProfiler.EF 默认会把MiniProfiler安装上,笔者程序是Asp.Net WebForm 不需要安装MiniProfiler.MVC3
 
2: 在Global.asax中添加下面代码

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

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

void Application_Start(object sender, EventArgs e)
{
  StackExchange.Profiling.MiniProfilerEF.Initialize();

}

3:在页面中添加

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

4:浏览该页面

点击左上角会出现,点击sql出现:
 

以上是关于性能工具MiniProfiler在Asp.Net WebForm跟踪EntityFramework的主要内容,如果未能解决你的问题,请参考以下文章