ASP. NET MVC5 use MiniProfiler to monitor MVC performance, mvc5miniprofiler

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.