Profile and debug your ASP. NET MVC app with Glimpse

Source: Internet
Author: User

Original: Http://www.asp.net/mvc/overview/performance/profile-and-debug-your-aspnet-mvc-app-with-glimpse

Glimpse provides detailed performance, debugging, and diagnostic capabilities for the ASP. It shows the key performance indicators below each page. When you need to understand the health of the server, you can get deep into your application.  Glimpse provides a lot of valuable information and I recommend that you use it in your development environment. The Fiddler and F-12 developer tools provide a view of the client, glimpse provides a detailed view of the data from the server side.  The following tutorials focus on using glimpse in ASP. NET MVC and EF, and of course glimpse there are many packages for XXX. Official document Dot this glimpse docs. Glimpse is an open source system.

Installing Glimpse

Install Glimpse Mvc5 and Glimpse EF6 packages:

Search for Glimpse.ef

Or

PM> Install-Package Glimpse.MVC5 
PM> Install-Package Glimpse.EF6

Turn on the glimpse feature for localhost

Open Http://localhost:<port #>/glimpse.axd page Select the Turn glimpse on button in the upper right corner

Now open localhost, Heads up Display (HUD) appears at the bottom of the page.

The Glimpse HUD page shows some time-consuming information in detail. These performance data can tell you immediately where the problem is-before you start the test. Click G in the lower right corner to appear in the following information panel:

In the above figure, the execution tag is selected, showing the timing information for the action and filter in the pipeline.

Timeline Label
Public ActionResult Index (int? id, int courseid, int? eager) {var ViewModel = new Instructorindexdata (); Viewmodel.instructors = db. Instructors. Include (i = i.officeassignment). Include (i = i.courses.select (c = c.department)).    (i = i.lastname); if (id! = NULL) {Viewbag.instructorid = ID.        Value; viewmodel.courses = ViewModel.Instructors.Where (i = i.id = = ID. Value). Single ().    Courses;       } if (CourseID! = null) {Viewbag.courseid = Courseid.value;          Eager Loading if (Eager! = null && Eager > 0) {viewbag.eagermsg = "Eager loading"; Viewmodel.enrollments = viewModel.Courses.Where (x = = X.courseid = = CourseID). Single ().       enrollments;        } else {//Explicit loading viewbag.eagermsg = "Explicit loading"; var selectedcourse = viewModel.Courses.Where (x = = X.courseid = = CourseID).        Single (); Db. ENtry (Selectedcourse). Collection (x = x.enrollments).        Load (); foreach (Enrollment enrollment in selectedcourse.enrollments) {db. Entry (Enrollment). Reference (x = x.student).        Load ();       } viewmodel.enrollments = selectedcourse.enrollments; }} return View (ViewModel);}

The above code allows us to pass a parameter ( eager ) to display the data. In the following diagram, the execution of the index action is shown:

In the code we put eager is set to 1:

You can view detailed information by placing the mouse in the corresponding event color block:

Models binding model bindings

The Model Binding tab provides us with some information to help us understand how our form parameters are bound to the model or why some of them are not binding as we expected. See the image on the right middle of the picture below, click on it to go to the Glimpse help page.

Routing

The Routes tab helps us debug and understand the routing situation. In the figure below, the product route is selected (green is selected).

Routing constraints, areas, and data tokens can be displayed. For more information see glimpse routes and attribute Routing in ASP. 5.

Profile and debug your ASP. NET MVC app with Glimpse

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.