Using Glimpse in ASP.NET Core

Posted by Anuraj on Saturday, January 30, 2016

ASP.NET5 MVC ASP.NET Core

This post is about integrating Glimpse in ASP.NET Core application. Glimpse is a web debugging and diagnostics tool used to gain a better understanding of whats happening inside of your ASP.NET application. First you need to add reference of Glimpse in the project.json file.

{
    "version": "1.0.0-*",
    "webroot": "wwwroot",
    "exclude": [
        "wwwroot"
    ],
    "packExclude": [
        "**.kproj",
        "**.user",
        "**.vspscc"
    ],
    "dependencies": {
        "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
        "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
        "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
        "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
        "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
        "Glimpse": "2.0.0-beta1"
    },
    "commands": {
        "web": "Microsoft.AspNet.Server.Kestrel --server.urls http://*:5004"
    },
    "frameworks": {
         "dnx451": { },
         "dnxcore50": { }
    }
}

And you need to configure the startup.cs file to add and use Glimpse. You need to add import Glimpse in the namespaces.

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc();
        services.AddGlimpse();
    }
    public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
    {
        loggerFactory.AddConsole();
        app.UseIISPlatformHandler();
        app.UseMvcWithDefaultRoute();
        app.UseGlimpse();
        app.UseWelcomePage();
    }
}	

Now Glimpse is configured. Now you can run the application with dnx web command. You can browse the page and Glimpse dashboard at the bottom of the screen like this.

Glimpse dashboard

And you can click on the right side and get more details like this. Since this is the hello mvc application, it doesn’t have data access and ajax calls.

Glimpse details

Happy Programming :)



Did you like this article? Share it with your friends

Facebook Twitter Google+ LinkedIn Reddit StumbleUpon



Subscribe


Copyright © 2017 - Anuraj P. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Hosted with ❤ by GitHub