Glimpse lets you see what’s happening on the server for your ASP.NET application, all within the browser and with no changes to the application.
What is going on?
We’ve all been in this situation: The code looks right and the page is displaying correctly, but execution isn’t matching expectations. You dig into the code and use the Visual Studio debugger among other tools.
The ability to see what’s happening on the server is valuable in this type of situation, and that’s where Glimpse enters. You add Glimpse to your Visual Studio application, and it opens a window in the web server. Debugging HTTP requests is possible via Fiddler or by using browser tools, but Glimpse offers more features and is tightly integrated with Visual Studio.
Getting and using Glimpse
The Glimpse home page prominently lists the three basic steps for using it within an ASP.NET application. The first step is adding it to your Visual Studio solution by way of the NuGet package manager. Right-click the solution and choose Manage NuGet Packages. Figure Ashows the available Glimpse packages found via the search box (upper right corner).
Adding Glimpse to a Visual Studio ASP.NET project via NuGet. (See an enlarged view of the image.)
The packages presented in Figure A are confusing, as there are multiple available; I figured out which to use for my project via trial and error. I could have saved time by reading the Glimpse online documentation, which provides all the details on what is necessary. Basically, the difference in what is used depends on whether the project uses WebForms or a version of MVC. I chose Glimpse ASP.NET for my test application. The Glimpse Core package will be installed with the other packages, so there’s no need to install it separately.
Figure B shows what is added to an application once Glimpse is installed. The NuGet installation path is the most straightforward, though Glimpse can be installed manually or via the command line as well. Other configuration options must be set up to use it; the documentation provides all of the necessary information.
Glimpse resources added to an ASP.NET application. (See an enlarged view of the image.)
What’s happening on the server?
Once Glimpse is installed, its interface is accessible via glimpse.axd on the web application’s URL. Figure C shows the page loaded on my Visual Studio local development server. The two links on the right of the page allow you to easily turn Glimpse on or off.
Glimpse page displayed when it is loaded on your server. (See an enlarged view of the image.)
Once Glimpse is enabled, its toolbar will appear on the bottom right of the browser window when the application is loaded. Figure D shows it displayed on my simple application — the left portion of the Glimpse toolbar has been selected, which is why it appears larger. The lowercase g at the far right of the toolbar (lower right of Figure D) opens and closes the full Glimpse interface when clicked. Figure E shows it opened.
The Glimpse toolbar appears in the browser once enabled. (See an enlarged view of the image.)
The Glimpse toolbar opened on a basic ASP.NET application. (See an enlarged view of the image.)
The Glimpse interface resembles many of the browser developer tools, such as Chrome’s Developer Tools. Glimpse provides the following eight basic areas.
- The Configuration tab provides information on the web server configuration (line connection strings and httpModules).
- The Environment tab provides details on the server environment.
- The Request tab provides details of the most recent HTTP request.
- The Routes tab routes setup on the server.
- The Server tab provides a snapshot of HTTP variables.
- The Session tab delivers information on the current session (if applicable).
- The Timeline tab offers the timing of the start and end of the HTTP request.
- The Trace tab presents trace information (if applicable).
Figure E shows the details of the Environment tab for my test environment, while Figure Fprovides information on my test server. Figure G shows the request history (link on top right of toolbar), as it gives you details on server requests. Other sections may be added depending on the tools being used. For example, a tab will show up to display details on SQL queries if you use the Entity Framework.
Server tab details for my test application. (See an enlarged view of the image.)
Glimpse allows you to easily view request history. (See an enlarged view of the image.)
A nice tool for peeking inside HTTP traffic
I’ve just started using Glimpse, but I’m already impressed with the information it provides with only a few clicks. While nobody likes to have application problems, I cannot wait for the next situation where I can rely on Glimpse to get a better idea of what’s happening on the server while a user is interacting with an application.
It will be interesting to see how it evolves. While Glimpse still doesn’t crack my top three tool selection, it’s very close to the browser tools included in the list.
Blog Post by Farai