WebApi exception trackingPosted Aug 7, 2014 | 2 min. (322 words)
Our Raygun4Net provider has recently been upgraded to support WebApi projects. This includes pure WebApi projects as well as ASP.Net projects that include WebApi. This is available right now in the latest version of the NuGet package. Just like all Raygun providers, it is extremely easy to set up in just a few minutes.
Not only will Raygun4Net register an exception-logger, it will also add a custom exception-filter, action-filter, controller-activator, controller-selector and action-selector that can detect exceptions that never reach the exception-logger.
Installation and usage
As with all .Net projects, the easiest way to start using Raygun is to install the NuGet package. To do this, right click your project in Visual Studio and select “Manage NuGet packages…”. Then search for “Raygun4Net” and either install the standard or signed version depending on what you need. NuGet will automatically reference the correct dll that contains new classes specific for sending exceptions from a WebApi project.
The set up starts off exactly the same as when setting up Raygun4Net in an ASP.Net application. First add the following section to the configSections tag of the Web.config file:
<section name="RaygunSettings" type="Mindscape.Raygun4Net.RaygunSettings, Mindscape.Raygun4Net" />
Next, add the RaygunSetting tag in the Web.config file and specify your application API key. This API key is given to you when you create a new application in your Raygunaccount. You can also view this key in the application-settings, or in your applications list.
<RaygunSettings apikey="YOUR_APP_API_KEY" />
And last off, call the static RaygunWebApiClient.Attach method within the Register method of your WebApiConfig class:
public static class WebApiConfig
public static void Register(HttpConfiguration config)
This will cause Raygun4Net to send all unhandled exception information to your Raygun dashboard.
And that’s it!
If you need exception tracking for your WebApi projects, grab the latest version of Raygun4Net from NuGet now. If you don’t have Raygun yet, sign up for a free 14 day trial – no credit card required.