Introduction To Glimpse in ASP.Net

Introduction

Today we'll talk about Glimpse. It may be possible that you are not aware of Glimpse yet, or you have some knowledge of Glimpse.

Glimpse is a free open source and diagnostics platform for the web. It works very well with ASP.NET and especially with ASP.NET MVC. It can be extended to the other project templates in the future.

What it does

Glimpse is very crucial for monitoring the diagnostics information about what is actually happening on the server directly in your page with a small Glimpse window that is completely rendered in JavaScript.

We can also say that Glimpse is so useful for the MVC template with which we can get all the information, like what the flow is running in the MVC pipeline and what controller is bound with the model. The entire idea of Glimpse is so useful.

If you are not using it with ASP.NET for debugging and profiling, you're missing out.

How to Get it

It's time to get this. You can install it from the NuGet Package Manager in your ASP.NET application. You need to install the correct NuGet packages for the ASP.NET feature you're using. As an example: I am using the MVC 5 application with Entity Framework 6, so I'll install Glimpse.Mvc5 and Glimpse.EF6.

Use the following procedure to install this in the application:

Step 1: In the application, open the Package Manager Console

Package Manager Console

Step 2: Enter the following command:

Install-Package Glimpse.Mvc5

NuGet Glipmse Package for Mvc5

Step 3: Now we'll install the package for Entity Framework 6 by entering the following command:

Install-Package Glimpse.EF6

NuGet Glipmse Package for EF6

Step 4: You can also install the package by right-clicking on "References" in the project in Solution Explorer and select "Manage NuGet Packages" and install Glimpse for ASP.NET

Glimpse in NuGet Package

Once the installation is complete, the Readme file opens.

Readme file of Glimpse

Your source editor will also be upgraded and a few entries are added to the Web.Config file as shown below:

Section in WebConfig

Glimpse in WebConfig

Getting Started

Glimpse is now installed on the application. It's time to launch the application.

Step 1: Run your application and add glimpse.xsd after the URL.

Glimpse in Localhost

Step 2: Just click on Turn Glimpse On to run

Turn on Glimpse

Step 3: Now open the controller to be executed in the browser.

Controller Information in Glimpse

In the preceding screenshot, I've hovered over a segment and you can see that it'll display the time spent rendering the methods of the app. The best thing is you can plug-in each tab of Glimpse.

Glimpse is not the background creeping around; you have absolute control over when you want it used.

In the following screenshot you can see the SQL query that is executed when every Person is displayed in the Index page and how much time is spent executing the query. Glimpse adds the modules and handlers. We can also turn on Glimpse for certain requests.

SQL Query in Glimpse

You can use Inspect mode (F12) developer tools to open in Chrome, Firefox and IE. Ensure that it is not a browser plugin.

Summary

We saw that Glimpse is open source and under the Apache 2.0 license. You can even write in the Glimpse tab. It is so easy to use. It replaces the Mini-Profiler as to Production Profiler for web apps and you can use Glimpse Elmah Plugin also. Thanks for reading.


Similar Articles