Getting Started With Glimpse In ASP.NET MVC

If you are using ASP.NET, especially if you are using ASP.NET MVC, you need to be using Glimpse.

I’m currently working on a more exhaustive Pluralsight course on Glimpse,  (the course is now live!) but I thought I’d write up a quick getting started tutorial here.

What is Glimpse?

Perhaps you haven’t heard of Glimpse yet, or you are just a little unsure of exactly what it is.

Glimpse is basically an open source and free diagnostics platform for the web.  Right now it works best with ASP.NET and especially ASP.NET MVC, but it can be extended to other platforms as well.  There is already work started for a PHP version and even a Python port.

What Glimpse essentially does is let you see diagnostics information about what is happening on your server directly in your page through a small diagnostics window completely rendered in JavaScript.

Out of the box, Glimpse can show you all kinds of information about your MVC application, like what routes are registered, what the flow was through the MVC pipeline and how the models were bound.

(BTW, if you are looking to brush up on your ASP.NET MVC 4 skills or learn about ASP.NET MVC 4, I recommend Professional ASP.NET MVC 4.  Great book, top notch authors.)

Here is what the Glimpse window looks like on a page.

Home Page   My ASP.NET MVC Application   Google Chrome 2013 05 19 09 30 58 thumb Getting Started With Glimpse In ASP.NET MVC

Glimpse is also fully extendable.

There are already plugins for Entity Framework, NHibernate, Ninject and many, many more

The best part about Glimpse is how easy it is to get setup.

I’ll walk you through the steps below.

Step 1: Get Glimpse from NuGet

All you have to do to get Glimpse installed is simply either:

  • Open up the Package Manager Console and type “Install-Package Glimpse.Mvc4” (or “Glimpse.AspNet if you aren’t using MVC)
  • Or, right click on your references, select Manage NuGet Packages, then search for Glimpse and find the appropriate Glimpse package.

GlimpseTutorial   Manage NuGet Packages 2013 05 19 09 44 14 thumb Getting Started With Glimpse In ASP.NET MVC

One you’ve done that, Glimpse will automatically add a few entries to your web.config for you.

2013 05 19 09 46 18 thumb Getting Started With Glimpse In ASP.NET MVC

2013 05 19 09 47 06 thumb Getting Started With Glimpse In ASP.NET MVC

2013 05 19 09 49 21 thumb Getting Started With Glimpse In ASP.NET MVC

Step 2: Turn on Glimpse

Turning on Glimpse is super easy.

Just launch your app and navigate to glimpse.axd.  Then, click “Turn Glimpse On” to set a cookie that will tell the Glimpse component running on the server to send you Glimpse data.

2013 05 19 09 52 16 thumb Getting Started With Glimpse In ASP.NET MVC

Go to glimpse.axd

Glimpse   Configuration Page   Google Chrome 2013 05 19 09 52 38 thumb Getting Started With Glimpse In ASP.NET MVC

Turn it on!

It’s that simple!

Step 3: Fire it up

Now all you have to do is navigate to any page in your application and you’ll see this little icon at the bottom right hand corner of the screen:

2013 05 19 09 55 28 thumb Getting Started With Glimpse In ASP.NET MVC

If you click the icon, you’ll see the Glimpse panel, which currently looks similar to the Chrome Dev Tools panel.

Home Page   My ASP.NET MVC Application   Google Chrome 2013 05 19 09 57 54 thumb Getting Started With Glimpse In ASP.NET MVC

Using Glimpse

Each tab contains different diagnostics information about your application.

This data can be extremely helpful in troubleshooting problems and learning about exactly what is going on inside of MVC.

You can also find plugins that can be easily installed from NuGet.

For example, if you add the Entity Framework plugin, you’ll start seeing a tab that shows data about EF queries, like this:

2013 05 19 10 04 46 thumb Getting Started With Glimpse In ASP.NET MVC

I’m pretty excited about Glimpse and its future.  Anthony van der Hoorn and Nik Molnar, the two creators and main maintainers for Glimpse, have done an excellent job transforming how we get diagnostics information for web applications.

One of the things I find most exciting about this platform is how easy it is to extend.  In my upcoming Pluralsight course, (the course is now live!) I walk you through creating a Glimpse plugin, which is surprisingly easy.

So if you haven’t checked out Glimpse, what are you waiting for?  Go do it now, it will take you about 5 minutes to get setup.

What do you think?  Are you using Glimpse already?  Post a comment and let me know.

My YouTube video for the week: (This is not an ad!)

Dealing With Burnout

And here is the weekly Get Up and Code episode:

  • Pingback: The Morning Brew - Chris Alcock » The Morning Brew #1359

  • Bill Braun

    John, How would you rate Glimpse’s Entity Framework plugin in comparison to MiniProfiler.EF?

    Nice intro btw.

    • jsonmez

      I believe the MiniProfiler.EF has a bit more data currently. But I think in most cases either one will work. The MiniProfiler.EF has a bit more guidance, like detecting duplicate queries or N+1 problems, where Glimpse is more showing you what you have.
      I’m not really an expert on the MiniProfiler, so perhaps someone with more experience will chime in.

  • B. Clay Shannon

    The icon looks kind of like a blue google, but glimpse sounds cool; can it be considered/used as a replacement for Chrome Dev Tools? IOW, does it provide you all the info that CDT does, and more (asp.net-specific)?

    • jsonmez

      It’s actually quite a different thing then the Chrome Dev Tools. Easy way to think about it is the Chrome Dev Tools tell you what is going on in the browser. Glimpse tells you what is going on in the server.
      I use them in conjunction.
      CDT = Domain specific for Chrome Browser
      Glimpse = Domain specific for ASP.NET

      • B. Clay Shannon

        Dang! I just tried to czech it out, and the console wouldn’t allow me to type into it, so I tried to use the GUI interface (Tools | Library Package Manager | Manage Nuget packages for solution) and entered “Glimpse” into the search box, but only got: “Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘EnvDTE._DTE’. This operation failed because the QueryInterface call …. failed due to … Library not registered…”

        • jsonmez

          Seems like some problems with NuGet in your VS install.
          Try updating NuGet package manager, or see if you can install any other NuGet packages.

          • B. Clay Shannon

            When I select Load Tools | Library Package Manager | Manage NuGet Packages for Solution, it comes up with Onlilne | NuGet official package source selected, I see the err msg mentioned in the middle pane.

            Similarly, perhaps, my project’s Output shows: Could not parse the configuration file. The error message is: ‘Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY))’. Try editing the file manually and then saving it.

            What configuration file is it talking about? Web.config? I see nothing unusual in it…I’m going to post a question in the asp.net msdn forum.

          • jsonmez

            Not sure, I haven’t seen that error.
            Try creating a brand new project and adding something from NuGet to find out whether it has to do with your project or not.

  • Luis Melgar

    Would this only be turned on only in Dev/QA?

    • jsonmez

      Great question.
      Personally, I turn it on in production as well, but I just lock down the usage of it.
      There are ways to control which clients the data is sent to and to put it in write only mode, (so it would write back the data for you to look at, but never send the data to the user.)

  • Pingback: Interesting .NET Links - May 20 , 2013 | TechBlog

  • http://about.me/dillieo Dillie-O

    I’ve been looking for some quick and easy profiling tools as of late! I’ve heard of MiniProfiler and now Glimpse! Thank you for this! With a diverse (and remote) team working on the same project, having “drop and run” type tools like this is essential!

  • Jatin

    Nice Article Man….Thanks

  • Pingback: Midnight Programmer

  • Pingback: Delgence

  • Pingback: JrpNetDev | Using Glimpse

  • Pingback: Debugging ASP.NET MVC applications with Glimpse | mcabraengineer.com

  • Hasan Ali

    John, I am excited to read this article.. planning on using it in my ongoing MVC project. Does it work well with Entity Framework / ODP.Net Oracle provider?

    • jsonmez

      You can use it with those. :)

    • Hasan Ali

      I tested it with EF5/MVC4/ODP.Net . It worked great. Wonderful tool. This can help save lot of time in diagnostics. Thanks