Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Airbrake Notifier for .NET
C# ASP
branch: master

This branch is 24 commits ahead, 85 commits behind airbrake:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.nuget
src
.gitignore
README.md
SharpBrake.Mvc.sln

README.md

SharpBrake

SharpBrake is a .NET library for use with the Airbrake exception reporting service by Thoughtbot. Airbrake allows you to easily track and get notification about exceptions that occur on your site.

The SharpBrake library can be used in two ways:

  1. You can programmatically report exceptions with the extension method SendToAirbrake() in a try/catch block.
  2. In MVC3 applications via a global filter GlobalFilters.Filters.Add(new SharpBrake.Mvc3.AirbrakeNoticeFilter())
  3. In MVC2 applications choose between the SharpBrake.Mvc.NotifierHttpModule and manually applying the SharpBrake.Mvc2.AirbrakeNoticeFilter , the module is installed by default with SharpBrake.Mvc2
  4. In classic ASP.NET applications use the SharpBrake.Mvc.NotifierHttpModule, installed via nuget by default with SharpBrake.Mvc2.

Usage

To use the library, you'll need to build the project and drop the files SharpBrake.Mvc.dll in your application's bin directory. To configure the library, you'll need to edit your application's .config file to include your API key for Airbrake:

<appSettings>
    <add key="Airbrake.ApiKey" value="1234567890abcdefg"/>
    <add key="Airbrake.Environment" value="dev" />
    <add key="Airbrake.LogInnerExceptions" value="true" />
</appSettings>

To programmatically report exceptions, all you need to do is ensure you've included the SharpBrake.Mvc namespace, and then call the SendToAirbrake() extension method on the exception. For example:

using SharpBrake;

try
{
    // some code
}
catch (Exception exception)
{
    // Oh noes!
    exception.SendToAirbrake();
}

Installation

For MVC3 Applications

Install the nuget SharpBrake.Mvc3 , this will create a WebActivator hook in App_Start which will register the global filter

GlobalFilters.Filters.Add(new SharpBrake.AirbrakeNoticeFilter());

For MVC2 Applications

You have two options, installing the nuget package SharpBrake.Mvc2 will create a web activator hook in App_Start which will register the SharpBrake.Mvc.NotifierHttpModule this will give you global exception handling, without the route data controller and action data Alternatively for Mvc2 you can use the SharpBrake.Mvc2.AirbrakeNoticeFilter attribute, unfortunatly in MVC2 you have to add this to all your controllers manually :/, though you can implement global filters in MVC2 with a custom controller factory, (see FluentFilters )

DynamicModuleUtility.RegisterModule(typeof(NotifierHttpModule));

Or

[AirbrakeNoticeFilter]
public class HomeController : Controller

Or

<httpModules>
    <add name="Airbrake" type="SharpBrake.NotifierHttpModule, SharpBrake"/>
</httpModules>
Something went wrong with that request. Please try again.