ASP. NET MVC5 use MiniProfiler to monitor MVC performance, mvc5miniprofiler
MiniProfiler is a simple and effective mini-analyzer that can monitor pages in real time. Other pages accessed through direct reference, Ajax, and Iframe are monitored. The monitoring content includes the database content and displays the SQL statements accessed by the database.
1. Install
Create an asp.net mvc Project
Right-click the project to manage the NuGet package. Install MiniProfiler. Mvc4 and MiniProfiler
Ps: MiniProfiler. MVC4 NuGet package (MVC5 is supported)
Alternatively, you can open the package management console and enter a command to install
Install-Package MiniProfiler -Version 3.2.0.157Install-Package MiniProfiler.Mvc4 -Version 3.0.11
2. Add the following contentApplication_Start()
In Global. asax
protected void Application_Start(){ ... GlobalFilters.Filters.Add(new ProfilingActionFilter()); var copy = ViewEngines.Engines.ToList(); ViewEngines.Engines.Clear(); foreach (var item in copy) { ViewEngines.Engines.Add(new ProfilingViewEngine(item)); }}
3. Add the following content to "Application_BeginRequest ()" and "Application_EndRequest ()", which are also in Global. asax.
protected void Application_BeginRequest(){ if (Request.IsLocal) { MiniProfiler.Start(); }}protected void Application_EndRequest(){ MiniProfiler.Stop();}
4. Add the following content to _ Layout. cshtml (</body>
Labels ):
@StackExchange.Profiling.MiniProfiler.RenderIncludes()</body>
5. Add the following contentIn the Web. config section:
<system.webServer> ...
If you use Entity Framework in the project, you can installMiniProfiler. EF6Software Package, inApplication_Start()
The following content is added at the end of Global. asax: MiniProfilerEF6.Initialize();
A simple monitoring of MVC performance is like this. In fact, it has many functions, such as detecting different parameters and highlighting the regions where the same query is executed. In this way, you can quickly find possible batch queries.
You can also record all ajax calls and view the analysis information of the last 100 analysis requests.
Result Display:
This article is self-created. If you have any questions, please comment below. repost the article to indicate the source.
If you have any help, please give me a thumbs up at the bottom right of the mouse. Your support is my greatest motivation.
Official MiniProfiler Website:Http://miniprofiler.com/