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 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 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 ):


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://

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: 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.