Take advantage of the Glimpse debugging and diagnostics tool to gain insight into the performance of your ASP.Net Core web application Credit: Ron Cogswell Glimpse is a popular, open-source web debugging and diagnostics tool that can be used to gain visibility into the performance of your ASP.Net or ASP.Net MVC applications. You can also integrate Glimpse with Application Insights. Glimpse provides an intuitive user interface that helps you examine the performance data of an application. Like MiniProfiler, Glimpse adds a widget to your web pages so that you can view performance data as you browse through the web pages of your application. You can read my article on MiniProfiler here. This article presents a discussion of how we can integrate Glimpse into an ASP.Net Core application. Create an ASP.Net Core Web API project First off, let’s create an ASP.Net Core Web API project. We’ll use this project to integrate Glimpse later in this article. If Visual Studio 2017 is up and running in your system, follow the steps given below to create a new ASP.Net Core Web API project in Visual Studio. Launch the Visual Studio 2017 IDE. Click on File > New > Project. Select “ASP.Net Web Application (.Net Framework)” from the list of the templates displayed. Specify a name for the project. Click OK to save the project. A new window “New ASP.Net Web Application…” is shown next. Select “Web API” as the project template. Ensure that the check boxes “Enable Docker Compose Support” and “Add unit tests” are unchecked as we won’t be using either of these here. Ensure that “No Authentication” is selected as we won’t be using authentication either. Click OK. This will create a new ASP.Net Core Web API project in Visual Studio. Next, to work with Glimpse in ASP.Net Core, we will need to install Glimpse in our project. There are two ways to install Glimpse in your application, i.e., either by downloading Glimpse from www.getglimpse.com or via NuGet. We’ll use NuGet. To install the Glimpse package in your application via NuGet, right-click on the project in the Solution Explorer window and select “Manage NuGet Packages…”. Then search for Glimpse.Mvc5 and click the Install button. IDG To install the Glimpse package, right-click on the project in the Solution Explorer window and select “Manage NuGet Packages…”. Then search for Glimpse.Mvc5 and click the Install button. Start the ASP.Net Core application and turn on Glimpse Once Glimpse has been installed and configured in your application, you can start exploring it. To enable Glimpse, start the application, go to the URL host/Glimpse.axd, and click on the “Turn Glimpse On” button in the top-right corner of the page (see figure below). IDG Once Glimpse has been turned on, you will see a “g” icon toward the bottom-right of the home page of your application. You’ll also see a Glimpse bar at the bottom of the web page. When you click on the “g” icon, you can see the execution details as shown in the figure below. IDG View details of an application in Glimpse tabs Glimpse contains several tabs that are used to show the details of the application, i.e., the routes that have been registered, connection strings being used, query strings being used, and much more. These tabs include the following: Configuration — provides information about the machine configuration Environment — provides information about the server that handles the request Execution — shows execution details, e.g., the time taken for the request Metadata — shows information related to the controller, action, and other metadata Model Binding — shows model binding information (if model binding is used by your application) Request — shows the exact data received by the server Routes — shows the routes that have been registered Server — shows the HTTP variables and their values Session — shows session data (if session is enabled for your application) Timeline — shows a timeline of the method calls that have been made in the server to render the web page Trace — shows any trace information specified in your application Views — shows information on the views and the view engines Add Glimpse to your ASP.Net Core application Once you have installed Glimpse in your ASP.Net Core project, you can write the following code in the ConfigureService method of Startup class to add Glimpse to the pipeline. public void ConfigureServices(IServiceCollection services) { if (this.HostingEnvironment.IsDevelopment()) { services.AddGlimpse(); } } Next, you should configure Glimpse in the Configure method of the Startup class as shown below. public void Configure(IApplicationBuilder applicationBuilder, ILoggerFactory loggerFactory) { if (this.HostingEnvironment.IsDevelopment()) { applicationBuilder.UseGlimpse(); } } You should add a reference to the Glimpse assembly in the Startup clas. Note that both the ConfigureServices and Configure methods are called by the runtime. Here is the complete code of the Startup class for your reference. public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public void ConfigureServices (IServiceCollection services) { services.AddGlimpse(); services.AddMvc().SetCompatibilityVersion (CompatibilityVersion.Version_2_2); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseGlimpse(); } app.UseMvc(); } } Glimpse is a free, open-source diagnostics platform that provides a great deal of performance and diagnostics information on your ASP.Net or ASP.Net Core applications. Glimpse can inspect web requests and give you insights and tooling to make debugging much easier. Related content news Wasmer WebAssembly platform now backs iOS Wasmer 5.0 release also features improved performance, a leaner codebase, and discontinued support for the Emscripten toolchain. By Paul Krill Oct 30, 2024 2 mins Mobile Development Web Development Software Development news analysis What Entrust certificate distrust means for developers Secure communications between web browsers and web servers depend on digital certificates backed by certificate authorities. What if the web browsers stop trusting your CA? By Travis Van Oct 30, 2024 9 mins Browser Security Web Development Application Security news Next.js 15 arrives with faster bundler High-performance Rust-based Turbopack bundler moves from beta to stable with the latest update of the React-based web framework. By Paul Krill Oct 24, 2024 2 mins JavaScript React Web Development feature WasmGC and the future of front-end Java development WebAssembly’s garbage collection extension makes it easier to run languages like Java on the front end. Could it be the start of a new era in web development? By Matthew Tyson Oct 16, 2024 10 mins Web Development Software Development Resources Videos