Exploring Prefix: A Free ASP.NET Profiling Tool

4.4 (10 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: 8260

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

Sivu 19/10/2016 08:21
In response to Entity Framework Core TrackGraph For Disconnected Data
Oh that's very very very nice ! Thanks for the write up Mike, much appreciated for the taking the to...

Mark 12/10/2016 16:42
In response to ASP.NET Web Pages vNext or Razor Pages
Although "Web Pages" was removed from the roadmap, has it just been renamed to "Razor Pages"?...

Satyabrata 12/10/2016 09:20
In response to Entity Framework Core TrackGraph For Disconnected Data
Nice article. Please write more articles featuring ASP.Net web pages. Thank you...

Julian 26/09/2016 14:27
In response to Loading ASP.NET Core MVC Views From A Database Or Other Location
Fantastic, many thanks Mike! Had got half way down this road before finding your article - saved...

Abolfazl Roshanzamir 14/09/2016 05:36
In response to Loading ASP.NET Core MVC Views From A Database Or Other Location
Nice article. Thanke you so much ....

cyrus 02/09/2016 15:12
In response to ASP.NET Web Pages vNext or Razor Pages
I've got some news. As Damian stated in this link: https://github.com/aspnet/Mvc/issues/5208 “We...

Simon 01/09/2016 08:00
In response to Loading ASP.NET Core MVC Views From A Database Or Other Location
Thanks Mike, nice post and exactly what I was looking for. Like you said, I think I'll opt to the...

dave 20/08/2016 14:57
In response to ASP.NET Web Pages vNext or Razor Pages
Do SimplemembershipProvider in viewpages is supported?...

Steven 18/08/2016 04:40
In response to Entity Framework Code First and Stored Procedures
Can you provide the directives (using statements) you're using for EF7 example?...

yousaid 17/08/2016 22:08
In response to ASP.NET Web Pages vNext or Razor Pages
Increasingly, learning a Microsoft tool is no longer worth the return on investment. Too many tools...