1:安装MiniProfiler


使用Nuget安装:

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

 

 
选择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:浏览该页面

性能工具MiniProfiler在Asp.Net WebForm跟踪EntityFramework
点击左上角会出现,点击sql出现:
 
性能工具MiniProfiler在Asp.Net WebForm跟踪EntityFramework

相关文章:

  • 2021-09-26
  • 2021-09-11
  • 2022-02-10
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-17
  • 2022-01-21
  • 2022-12-23
  • 2021-12-18
  • 2021-11-06
相关资源
相似解决方案