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.157
Install-Package MiniProfiler. Mvc4-Version 3.0.11
2. Add the following content to Application_Start () 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 (just before the </body> label ):
@StackExchange.Profiling.MiniProfiler.RenderIncludes()</body>
5. Add the following content to the :
<system.webServer> ...
If you use Entity Framework in the project, you can install MiniProfiler. EF6 and add the following content at the end of Application_Start () in 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:
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.