Scott Hanselman

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

July 20, 2013 Comment on this post [40] Posted in ASP.NET | ASP.NET MVC | Open Source | Tools
Sponsored By
Glimpse NuGet packages

I've blogged about Glimpse since the day I first saw it at Mix 2011's open source fest. It's popular, but frankly, Glimpse is so useful more people need to know about it.

From within your ASP.NET application in Visual Studio, install Glimpse using NuGet. You'll want to install the right Glimpse packages for the ASP.NET features you're using. For example, I'm using MVC4 and Entity Framework 5, so I will use NuGet and:

install-package Glimpse.MVC4
install-package Glimpse.EF5

These packages pull in the core Glimpse libraries plus the hooks for the specific ASP.NET modules and handlers needed for Glimpse to collect all the information about your application and present it to the client side. Be sure to pick the right NuGet packages for your project type.

The releases of Glimpse 1.4.0, and now most recently 1.5.0 improve Glimpse with the addition of a really amazing HUD (Heads Up Display). As you hover over each segment, it pops up with lots of details about the HTTP request, AJAX requests, deep inspection database interactions, and lots more.

Glimpse's new HUD

Here I've hovered over one segment and you can see the time it took to render this first page, and exactly how much time was spent during each activity, from rendering to action methods to database connections.

The Glimpse HUD expanded

You can move from the HUD to the standard Glimpse view. The best part is that each Glimpse Tab is a plugin itself! There's a whole community creating Glimpse Plugins. If you're using RavenDB, or NHibernate, or SignalR or whatever, you can get introspection into what's going on in a Glimpse Tab.

You turn Glimpse on and off with cookies, and you can setup security policy however you want. Glimpse isn't in the background creeping around - you have absolute control over when you want it used. Perhaps local and only when debugging, or perhaps always and with a specific cookie value, it's up to you.

Below you can see the actual SQL query executed by my Entity Framework code and how long it took to execute. I didn't have to change any part of my code or do anything more than just install Glimpse. Glimpse added the modules and handlers, and Glimpse policies can be installed to turn Glimpse on or off based on any option I can think of. I can even put Glimpse into production and only turn it on for certain requests, giving me a profiling tool I can peek at whenever I like.

EF SQL queries viewed within Glimpse

You likely use F12 developer tools in Chrome, IE and Firefox, and you've seen Timeline views before. But remember that Glimpse is JavaScript and HTML on the client - it's NOT a browser plugin - and it's a series of plugins on the server that give you a holistic view that's way more than just what's visible on the client.

Glimpse's Timeline View shows you exactly what's happening on the server, how long it's taking, and how it all fits together.


Sessions within Glimpse are all tracked and be optionally named. Since the server is collecting what's going on, you can pull out a popup browser window of Glimpse and connect to sessions from other browsers. Below I'm using an iPhone mobile emulator from ElectricPlum and inspecting requests from another browser window.

Using Glimpse to debug remotely against an iPhone Emulator

Glimpse is all open source and under the Apache 2.0 license. You can certainly help out, but the most interesting thing in my opinion is writing Glimpse Tabs - extending Glimpse to collect and show new data. Tabs can show technical stuff, but even business stuff that's specific to your application or style of application. For example, the Umbraco CMS could make a Glimpse Tab that puts configuration or technical Umbraco specific details up front. A line of business app could show tax details or shopping cart contents.

Glimpse is so useful that it's the first thing I install after I File | New Project on any non-trivial thing I'm working on. It's replaced Mini-Profiler as my go-to "production profiler" for web apps, and if you use ELMAH to collect and manage your application errors, there's even a Glimpse ELMAH plugin!

Check it out and go talk to Anthony and Nik about Glimpse on Twitter and thank for their work!

DISCLOSURE NOTE: The Red Gate company sponsors the Glimpse open source project. Red Gate also sponsored my blog feed this week. That is a cool coincidence, but it's just a coincidence. Red Gate does a lot of stuff. This post about Glimpse was written earlier. Just an FYI for y'all.

Sponsor: Big thanks to the folks at Red Gate for sponsoring the feed this week. Take a moment and check out their free download of Deployment Manager! Easy release management: Deploy your .NET apps, services and SQL Server databases in a single, repeatable process with Red Gate’s Deployment Manager. There’s a free Starter edition, so get started now!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
July 20, 2013 12:31
The information displayed by Glimpse has always been useful, but the new HUD is so much prettier. It's also cool that Glimpse can also aid with client-side debugging: Now, there even is a KnockoutJS plugin allowing us to inspect view models.

Fingers crossed that even more devs start using it!
July 20, 2013 15:28
The Scott has spoken.

Installing it today before breakfast.

Thank you.
July 20, 2013 15:55
Unfortunately, does not work.

Uninstalling right after 5 minutes again. Sad :-(
July 20, 2013 16:29
Replaces MiniProfiler for you? Wow. Time to try out Glimpse on some of my sites. I definitely like the look a lot better than MiniProfiler.
July 20, 2013 19:52
hi Scott,thanks for your nice post, it's usable just in MVC4 ??
July 20, 2013 20:13
I installed the basic packages and I ended up getting an error right off the bat:

Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'Glimpse'

I had to do a little web.config hacking. In the system.webserver section add a remove name="Glimpse" in the modules and handlers areas before it would work.
July 20, 2013 20:15
Esan, they have mvc3 and mvc2 packages on nuget. There's even a request for mvc1 in the issues list.
July 21, 2013 4:42
Scott, this is such a solid tool.
Ive plugged it straight into an MVC4 project I am working on and the information in provides is so valuable.

How do you find out about all these tools?
July 21, 2013 13:24
A really nice tool. I already installed it, and love it! Thanks for the info, Scott!
July 21, 2013 13:56
Awesome tool. Will be testing tomorrow at work.
Are you aware of any similar tool(s) but for WPF applications?
July 21, 2013 17:33
Thanks Scott,

It woukd appear that the guys that developed FriendlyUrls are going against the spirit of openness in Asp.Net by sealing it, making it closed source, and causing the issue that Uwe reported. Please hassle them so that more devs can use the goodness of Glimpse.
July 22, 2013 0:31
I installed Glimpse, I believe, after reading your last blog about it. I fiddled with it but didn't have time to figure out why the sql logging wasn't working. I just updated based on your new information and it's working like a charm. Thanks for sharing the updated information. I have found it very useful.

I also have been using your MVCScaffolding project and have been able to modify the templates for my purposes. I found the tool extremely useful as a starting place getting into EF, repositories, and mvc in general. Thanks again for sharing that code. :)
July 22, 2013 7:52
why are friendly urls so unfriendly why are web forms treated like the plague it's like MVC is the only technology I get this when I installed glimps Unable to cast object of type 'Castle.Proxies.RouteBaseProxy' to type 'Microsoft.AspNet.FriendlyUrls.FriendlyUrlRoute'. it's like if your a web forms developer your on your own every thing is MVC Web Forms seem like a wasted investment of late we get crumbs
July 22, 2013 7:54
Rickj1, James and others: We're looking at the FriendlyUrls thing now. Web Forms is part of One ASP.NET and we're trying to make it all work together.
July 22, 2013 16:50
I like the new Glimpse and I was hoping it would/could replace miniprofiler for us. But ever since I found out you could set miniprofiler to display better SQL output, ie it adds the variable declarations and values, it is hard to get rid of. Glimpse did not do this, at least for linq to sql. Also for the life of me I could not get glimpse to ignore the miniprofiler ajax requests.
July 22, 2013 19:24
MiniProfiler has a feature to monitor WCF calls (and even EntityFramework calls behind the WCF Service: ASP.NET->WCF->EF)

I don't see something equivalent with Glimpse.
July 22, 2013 21:23
Wow! Very nice. A snap to install in MVC. I now have three standard (3rd party) libraries in my MVC toolbelt, Elmah, Unity, and Glimpse. That's more bloat than I like but as soon as MEF can handle interception, I will stop using Unity.
July 22, 2013 22:39
rickj1 - It looks like the error for .NET webforms ('Castle.Proxies.RouteBaseProxy' to type 'Microsoft.AspNet.FriendlyUrls.FriendlyUrlRoute') is being addressed / discussed over at the Glimpse Github site

July 22, 2013 22:42
Nice, will try it soon
July 23, 2013 0:11
I'm on of the co-founders of Glimpse.

@FriendlyUrlRoute We are looking to see what we can do here so it doesn't break out of the box. Within the next week we should have something that fixes this up. Watch the blog for more details -

@Ubikuity We don't currently have a WCF component. Its not that its rocket science but we have been going where the community points us and todate, WCF hasn't been a priority. If you could go to the issues list and raise support there we might be able to get something rolling. You might also be interested in this one -

@NickPortelli We do replace the arguments in the SQL tab with the values of the argument. The intent is to make it easy to be able to copy out and put into SSMS. See here as an example - If you aren't seeing this in your code, then we will need to take a look at it. By default there is no way to get particular ajax calls ignored (didn't think of that use case) but its a great idea. If you want to add to the issues list, let see if we can get it in.

@Everyone Thanks for the positive feedback and support.
July 23, 2013 0:19
Any chance to get this nice piece of software to work with single page apps which interact with the server only via .NET WebAPI?
July 23, 2013 0:42
Thanks for you interest everyone.

We are working with the ASP.NET team to figure out the best solution for the FriendlyUrl problem. Please keep an eye on on this issue for the most up to date information.

@Nick Portelli - please submit an issue on GitHub describing the feature you'd like. It will most likely be added!

July 23, 2013 7:00
It seems that it only supports EF for data access, can I use it with Dapper.NET?

July 23, 2013 10:57
Awesome tool. Love it. Getting the times end-to-end is a big plus.
July 23, 2013 17:19
I am using postal in mvc 4 for sending emails in the application .
After installing glimpse ,it seems the app is unable to recognize the send property of email Class ?

Any ideas ?
July 24, 2013 2:39
I installed this and started getting build errors. Even worse, uninstalling it totally hosed my web.config. Won't be playing with this again.
July 24, 2013 10:45
It is not working with Autofac integration getting errors.
July 24, 2013 21:46
Thanks for reminding me how awesome glimpse is! I played with this in the early days but wow have they done a lot of work since then. Every dev needs to be using this.
July 24, 2013 21:57
We're using EF6 and can't seem to get Glimpse to work at all.
Keep getting this error:

Unable to cast object of type 'Glimpse.Ado.AlternateType.GlimpseDbConnection' to type 'System.Data.SqlClient.SqlConnection'

Even after following the documentation to initialize Ado and EF in Application Start.

It looks nice though.
July 24, 2013 23:15
Tien, use Glimpse.ADO and you should be good to go.

Sri - we're not familiar with Postal. Could you describe your issue on StackOverflow and we'll help you out. Just be sure to use the 'glimpse' tag.

Richard and Balajj - open these as issues on GitHub and we'll track down the problem.

July 25, 2013 4:40
After a lot of effort (and finding a bug which I've raised on their github), I've managed to get Glimpse working on my company's Web Forms product. But I'm unable to see all the really great metadata that Scott seems to have got going on in this blog post, especially the granular information on the timeline, which is what I REALLY wanted.

Is this because it's Web Forms? I guess I'd better play around more, with an MVC (or even a brand new Web Forms) project to see if Glimpse is capable of showing all the stuff I was expecting.
July 25, 2013 22:10

At this point, Glimpse certainly provides more diagnostics information for MVC than WebForms. We are continually working to improve the WebForms story - and would love to hear your ideas. Feel free to reach out to us on GitHub and we'll work through this together.
July 30, 2013 0:54
Thanks Scott,

This is an amazing tool. This information is extremely helpful.
August 01, 2013 16:27
@FriendlyUrls - I have some good news. As of 1.0.2 of FriendlyUrls this issue will be fixed. Please see that update when it comes out.
August 07, 2013 20:06
Thanks Scot and Glimpse Team.

In IE10, with compatibility-mode = 'on', java script error whenever Glimpse Turned on.

I have some stuff that works only with IE Comapatibility-mode='on'.

Thanks in advance,

August 17, 2013 20:50
Wow! MiniProfiler replaced. Like how non-intrusive it is as well as how it auto configures itself in MVC4
August 23, 2013 13:04
Thanks Scott!!
Its great and useful.
Eager to see the results.
Just finished installing it.
September 02, 2013 13:10
Hey Scott,

I tried Glimpse MVC 3. It ran successfully with my MVC 3 application and I was amazed with the level of details it provided.
Later when I decided to uninstall it using nuget, it messed up all config files. I had to do a manual cleaning of the config files, browser cache and cleared "Temporary ASP.NET Files" folder then only I was able to run the application successfully again.
Please let me know is there any graceful way of uninstalling the nuget Glimpse and clearing config files.

Soumen Banerjee
November 25, 2013 12:02
Thanks Scott,

I installed and checked this tool with existing application. It is awesome one and display is very good. Thanks for sharing this.
November 26, 2013 21:07
In one of our MVC/EF projects, we tried to integrate MiniProfiler but after reading this post, we left it and installed Glimpse. So far so good. It allows us to analyze the bottlenecks and poorly written code easily as we navigate through the pages.

I think such tools increase the quality of the code in the development phase because it gives the programmer to get clear insights about how to optimize his/her code.

Thanks for sharing.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.