MiniProfiler是一个简单有效的mini profiler,可以有效地实时监控页面。其他以直接引用、Ajax和Iframe形式访问的页面用于监控。监控内容包括数据库内容,可以显示数据库访问的SQL。
1.装置
首先,在ASP.NET创建一个新的MVC项目
右键单击项目并管理NuGet包。安装MiniProfiler。Mvc4和MiniProfiler
ps:MiniProfiler的NuGet包。MVC4(此MVC4包支持MVC5)
或者,您可以打开软件包管理控制台并输入命令来安装它
安装包迷你分析器-3.2.0.157版
Install-Package MiniProfiler。MVC 4-版本3.0.11
2.将以下内容添加到Application_Start()Global.asax
受保护的void Application _ Start(){ 0.全局过滤器。筛选器。添加(新的profiling actionfilter());var copy=ViewEngines。engines . to list();视图引擎。引擎。清除();foreach(副本中的var项目){ ViewEngines。引擎。添加(新的ProfilingViewEngine(项目));}}3.同样在Global.asax中,在“Application_BeginRequest()”和“Application_EndRequest()”中添加以下内容
受保护的void Application _ BeginRequest(){ if(Request。IsLocal) { MiniProfiler。start();} }受保护的void Application _ EndRequest(){ MiniProfiler。stop();}4.将以下内容添加到_Layout.cshtml(就在/body标记之前):
@ stack exchange . profiling . mini profiler . render includes()/body/html 5。将以下内容添加到handlersWeb.config的部分:
system.webServer.经理人.添加名称='MiniProfiler '路径='mini-profiler-resources/* '动词='* '类型='System。web . routing . urrlrouting module ' resource type=' Unspecified ' preference=' integrated mode '/./handlers/System.webServer如果在项目中使用实体框架,则可以安装MiniProfiler。EF6打包并在Application_Start()中的Global.asax末尾添加以下内容:MiniProfilerEF6。初始化();
这是对MVC性能的简单监控。事实上,它有许多功能,例如能够检测不同的参数并突出显示执行相同查询的区域。这样,您可以快速找到可能的批处理查询。
您还可以记录所有ajax调用,并查看最近100个分析请求的分析信息。
结果显示:
以上就是本文的全部内容。希望对大家的学习有帮助,支持我们。