.NET Agent Installation: Configure Self Hosted Web API

Retrace automatically supports Web API transactions that are hosted within an IIS application. If you are “self hosting” Web API in a Windows Service, please use these directions.

1. Configure Retrace to know about and profile your application

By default Retrace only profiles IIS applications. Please review this article on how to tell it to profile your application: .NET Agent Installation: Configure Windows Services

 2. Add the Stackify Web API Message Handler to your application

Web API can be self hosted in a Windows Service or console app, outside of IIS. A Message Handler needs to be added to your code and can be installed via a nuget package. This Message Handler allows Retrace to recognize when transactions begin and end.  Find the nuget package download here: Stackify Web API Message Handler

Via nuget:

Install-Package StackifyWebApiMessageHandler

Your code will look similar to the example below. You only need to add our Message Handler.