Asp. NET how to monitor MVC performance with MVC5 's Miniprofiler

Source: Internet
Author: User
This article is mainly for you to introduce in detail the ASP. MVC5 using Miniprofiler to monitor MVC performance, with a certain reference value, interested in small partners can refer to

Miniprofiler, a simple and effective mini-profiler, can effectively monitor the page in real time. Monitor the contents of the database by direct reference, Ajax, and other pages accessed in the form of an IFRAME, and can display SQL for database access.

1. Installation

Create an ASP. NET MVC Project First

Right-click the project and manage the NuGet package. Installing Miniprofiler.mvc4 and Miniprofiler

Ps:MiniProfiler.MVC4 's NuGet package (the MVC4 package supports MVC5)

Alternatively, you can open the Package Management Console input command to install

Install-package miniprofiler-version 3.2.0.157

Install-package miniprofiler.mvc4-version 3.0.11

2. Add the following 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 to "Application_BeginRequest ()" and "Application_EndRequest ()", also in Global.asax


protected void Application_BeginRequest () {if (request.islocal) {  miniprofiler.start ();}} protected void Application_EndRequest () {miniprofiler.stop ();}

4. Add the following to the _layout.cshtml (just before the </body> tag):


@StackExchange. Profiling.MiniProfiler.RenderIncludes () </body>

5. Add the following to the :


<system.webServer> 

If you use the entity Framework in your project, you can install the MINIPROFILER.EF6 package and add the following at Application_Start () at the end of the Global.asax: Miniprofileref6.initialize ();

A simple way to monitor MVC performance is that, in fact, he has many features, such as the ability to detect and highlight areas that perform the same query with different parameters. This allows you to quickly find queries that may be in bulk.

You can also record all of the AJAX calls, view analysis information for the last 100 analysis requests, and more.

Results show:

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.