Exploring Prefix: A Free ASP.NET Profiling Tool

4.5 (12 votes)

Prefix is a free profiler for ASP.NET applications. It's dead easy to use and it will help you find bugs in your code that you didn't even know you had. I found two in what I thought were properly working apps within an hour of downloading Prefix.

Prefix is developed by a company called Stackify, who also do some heavy-weight application performance monitoring kit. The Prefix download is a standard msi so it is easy to install, and once installed, it runs in the background and is available from the system tray.

Stackify Prefix

Prefix uses a browser for its UI. When you click on the system tray icon, the notification lets you know that it is waiting for new web requests to profile.

Stackify Prefix

It is not immediately clear whether the profiler has been enabled as both the Enable Profiler and Disable Profiler buttons appear in the same indeterminate state. However, as soon as you fire an application up in IIS Express, you can see whether it is being profiled:

Stackify Prefix

Each individual request is monitored. In the image above, you can see an Intranet application being started. The default home page is initially requested, and the response is a 302 redirect to the login page. This happens to be an MVC application, but Prefix works with Web Forms and Razor Web Pages applications just as well. ASP.NET Core support is coming soon, we are promised.

The left hand side of the screen shows each request, with the time it took, the response status, the number of database calls the request required and the number of uncaught exceptions (if any).

Stackify Prefix

The right hand side of the screen allows you to drill down into the detail of each request. For example you can examine the request headers:

Stackify Prefix

You can get this type of detail from any browser extension, but what you can't get from there is a breakdown of the compilation time and the modules and handlers in the request pipeline such as the following example that features a request to a Web Forms application:

Stackify Prefix

You also get a visual breakdown of what resources are being used most during page execution:

Stackify Prefix

Prefix captures the command text that's executed against the database. In the image above, you can see a stored procedure called GetFeaturedSupplier taking 1.335 seconds to execute. At the moment, it doesn't monitor parameter values, but that feature is being added. Being able to see the command text is particularly useful if you are using Entity Framework because you can you examine the generated SQL easily:

Stackify Prefix

A nice feature is the Download Query Result counter (in the yellow box above), which tells you how much of the database call time was used for transferring the resulting data, as opposed to executing the actual query.

The details pane shows particularly expensive operations with a different colour background:

Stackify Prefix

In this particular case, the view compilation took most time. While that's a one-off cost, it could be worth considering precomiling the views. The point is that Prefix details exactly what it is that you should be focusing on to improve performance.

As to the bugs that Prefix helped me identify, one was the same stored procedure being called twice in the same page in a Web Forms application. This was caused by the fact that I had changed some code to explicitly call the Select method of a SqlDataSource control in code behind while the control was still bound to a ListView, resulting in the Select method being fired twice. The other bug was an Action being fired twice in quick succession (which wasn't noticeable in production) resulting in an unnecessary extra 12 calls to the database:

Stackify Prefix

On closer examination, it was clear from the request headers that the second request was being initiated by AJAX. The culprit was a mistake in some jQuery code, where AJAX caching was incorrectly configured as follows:

$.ajax({ cache: false });

instead of

$.ajaxSetup({ cache: false });

The original code will of course result in an asynchronous call being generated.

Summary

Prefix is a very useful tool for seeing exactly what is going on within your ASP.NET application during development. It is extremely lightweight and is easily accessible from the system tray. It will help you identify any potential processing bottlenecks, as well as hidden bugs. It's definitely become part of my toolkit.

You might also like...

Date Posted:
Last Updated:
Posted by:
Total Views to date: 9918

5 Comments

- Matt Watson

Glad you are loving it!

Matt from Stackify

- Jon

We had the exact same experience, finding multiple bugs in an application that we thought was running pretty smoothly, within minutes of beginning to use Prefix! Nice write up on a welcome new addition to the .NET community's toolbelt!

- satyabrata

This is great!!!!!

- Darren Evans

'Tis indeed a marvellous thing. Just waiting on its appearance for ASP.NET Core. Hopefully not long now. I see there's already a StackifyMiddleware Nuget package ready and waiting.

Thanks to the Stackify code monkeys for this great tool.

- Avinash Setty

This tool is awesome! I am very thankful for introducing this tool for us! By any chance, do you know whether this tool is worthy to install it on Production servers? Also, by default Prefix captures the requests for last 5mins, do you know how to extend this?

Recent Comments

Pam 30/08/2017 11:30
In response to Sending Email in Razor Pages
Mike, RazorPages sound like a nice choice for somebody still working in ASP classic who wants to to...

Robby Robson 15/08/2017 00:43
In response to Routing in Razor Pages
Mike: great stuff. Now that .Core Standard 2.0 is formally out, how soon will you rewrite your book...

Satyabrata Mohapatra 28/07/2017 08:59
In response to Sending Email in Razor Pages
Bit off topic, but congratulation sir for your MVP award. You deserve it !!!...

Satyabrata Mohapatra 23/07/2017 16:43
In response to Razor Pages - The Elevator Pitch
@Dale Severin You can continue to build apps using asp.net web pages....

Satyabrata Mohapatra 23/07/2017 16:40
In response to Sending Email in Razor Pages
Thanks for sharing...learned a lot...

Gfw 22/07/2017 11:53
In response to Sending Email in Razor Pages
Question... Does System.Net.Mail support SSL?...

Dale Severin 20/07/2017 03:38
In response to Razor Pages - The Elevator Pitch
I work with razor web pages extensively. I appreciate the rapid development it permits me to I am as...

Obinna Okafor 14/07/2017 01:19
In response to Routing in Razor Pages
Thank you, Mike. Good post....

Satyabrata Mohapatra 11/07/2017 16:02
In response to Routing in Razor Pages
Very powerful routing system!!...

Cyrus 05/07/2017 03:41
In response to Razor Pages - Getting Started With The Preview
How can I trim packages and services as much as possible to use just razor pages? I don’t want to to...