Trace execution path in Web API


In the below post we are going to see that how we can trace an Web API execution path for any request and see what processing path it is following internally .

For that your project should have “Microsoft.AspNet.WebApi.Tracing” package installed .You can install it using NuGet package manager , other

alternatives are install Asp.Net and Web Tools 2012.2 . below is the link of Scott blog which have information about the link.

Now , we are going to use the “Microsoft.AspNet.WebApi.Tracing” package to enable the tracing for your Web API project.

Open your Web API project and go to Tools—>Library Package Manager—>Package Manager Console and click on it.


it will open package manager console as below.


Now on the console, type “Install-Package Microsoft.AspNet.WebApi.Tracing” and press Enter (Make sure you connected to internet) . it will generate the information much similar

to below and install the package.


Now the tracing package is installed on your project after successful installation it will open a readme.txt file which gives information about “Microsoft ASP.NET Web API Tracing” .


You can see the readme file gives clear information about how to enable tracing. below is the line of code which does this magic.


since we are using the Web API project template so we need to add the above line in the Register method of WebApiConfig.cs or vb file which you can

find on App_Start directory.


add the code as below.


Now we are ready to trace. As a sample I am using Web API ValuesController class .

Clear your Visual studio Output Window and Call the Values controller class method by passing the “10” as parameter


Now go to the Output Window again , you can see that it generated useful piece of information about how your request processed under Web API .


You can investigate these information for further information about your methods execution path, how the values get bind , Which class is doing what etc.

Hope you find this post useful , thanks for reading 🙂

Technorati Tags:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s