Mindscape.Raygun4Net.Mvc 11.0.2

dotnet add package Mindscape.Raygun4Net.Mvc --version 11.0.2                
NuGet\Install-Package Mindscape.Raygun4Net.Mvc -Version 11.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mindscape.Raygun4Net.Mvc" Version="11.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mindscape.Raygun4Net.Mvc --version 11.0.2                
#r "nuget: Mindscape.Raygun4Net.Mvc, 11.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Mindscape.Raygun4Net.Mvc as a Cake Addin
#addin nuget:?package=Mindscape.Raygun4Net.Mvc&version=11.0.2

// Install Mindscape.Raygun4Net.Mvc as a Cake Tool
#tool nuget:?package=Mindscape.Raygun4Net.Mvc&version=11.0.2                

Raygun4Net.Mvc - Raygun Provider for ASP .NET Framework MVC projects

Where is my app API key?

When you create a new application in your Raygun dashboard, your app API key is displayed at the top of the instructions page. You can also find the API key by clicking the "Application Settings" button in the side bar of the Raygun dashboard.


The main classes can be found in the Mindscape.Raygun4Net namespace.


The following instructions are for ASP.NET Framework MVC. For instructions for how to install Raygun for ASP.NET Core MVC, see the Mindscape.Raygun4Net.AspNetCore provider here.

In your Web.config file, find or add a <configSections> element, which should be nested under the <configuration> element, and add the following entry:

<section name="RaygunSettings" type="Mindscape.Raygun4Net.RaygunSettings, Mindscape.Raygun4Net"/>

Then reference it by adding the following line somewhere after the configSections tag.

<RaygunSettings apikey="YOUR_APP_API_KEY" />

Now you can either setup Raygun to send unhandled exceptions automatically or/and send exceptions manually.

To send unhandled exceptions automatically, use the Raygun HTTP module within the <configuration> element in web.config. This is done slightly differently depending on what version of IIS you're using. If in doubt, just try them both:

    <add name="RaygunErrorModule" type="Mindscape.Raygun4Net.RaygunHttpModule"/>

For IIS 7.0, use system.webServer

    <add name="RaygunErrorModule" type="Mindscape.Raygun4Net.RaygunHttpModule"/>

Anywhere in you code, you can also send exception reports manually simply by creating a new instance of the RaygunClient and call one of the Send or SendInBackground methods. This is most commonly used to send exceptions caught in a try/catch block.

catch (Exception e)
  new RaygunClient().SendInBackground(e);

Or to send exceptions in your own handlers rather than using the automatic setup above.

protected void Application_Error()
  var exception = Server.GetLastError();
  new RaygunClient().Send(exception);

Providing a custom RaygunClient to the http module

Sometimes when setting up Raygun using the http module to send exceptions automatically, you may need to provide the http module with a custom RaygunClient instance in order to use some of the optional feature described below. To do this, get your Http Application to implement the IRaygunApplication interface. Implement the GenerateRaygunClient method to return a new (or previously created) RaygunClient instance. The http module will use the RaygunClient returned from this method to send the unhandled exceptions. In this method you can setup any additional options on the RaygunClient instance that you need - more information about each feature is described below.

Additional configuration options and features

Exclude errors by HTTP status code

If using the HTTP module, then you can exclude errors by their HTTP status code by providing a comma separated list of status codes to ignore in the configuration. For example if you wanted to exclude errors that return the "I'm a teapot" response code (http://tools.ietf.org/html/rfc2324), you could use the configuration below.

<RaygunSettings apikey="YOUR_APP_API_KEY" excludeHttpStatusCodes="418" />

Exclude errors that originate from a local origin

Toggle this boolean and the HTTP module will not send errors to Raygun if the request originated from a local origin. i.e. A way to prevent local debug/development from notifying Raygun without having to resort to Web.config transforms.

<RaygunSettings apikey="YOUR_APP_API_KEY" excludeErrorsFromLocal="true" />

Remove sensitive request data

If you have sensitive data in an HTTP request that you wish to prevent being transmitted to Raygun, you can provide lists of possible keys (names) to remove. Keys to ignore can be specified on the RaygunSettings tag in web.config, (or you can use the equivalent methods on RaygunClient if you are setting things up in code). The available options are:

ignoreSensitiveFieldNames ignoreQueryParameterNames ignoreFormFieldNames ignoreHeaderNames ignoreCookieNames ignoreServerVariableNames

These can be set to be a comma separated list of keys to ignore. Setting an option as * will indicate that all the keys will not be sent to Raygun. Placing * before, after or at both ends of a key will perform an ends-with, starts-with or contains operation respectively. For example, ignoreFormFieldNames="password" will cause Raygun to ignore all form fields that contain "password" anywhere in the name. These options are not case sensitive.

Note: The IgnoreSensitiveFieldNames will be applied to ALL fields in the RaygunRequestMessage.

We provide extra options for removing sensitive data from the request raw data. This comes in the form of filters as implemented by the IRaygunDataFilter interface. These filters read the raw data and strip values whose keys match those found in the RaygunSettings IgnoreSensitiveFieldNames property.

We currently provide two implementations with this provider.

RaygunKeyValuePairDataFilter e.g. filtering "user=raygun&password=pewpew" RaygunXmlDataFilter e.g. filtering "<password>pewpew</password>"

These filters are initially disabled and can be enbled through the RaygunSettings class. You may also provide your own implementation of the IRaygunDataFilter and pass this to the RaygunClient to use when filtering raw data. An example for implementing an JSON filter can be found at the end of this readme.

Modify or cancel message

On a RaygunClient instance, attach an event handler to the SendingMessage event. This event handler will be called just before the RaygunClient sends an exception - either automatically or manually. The event arguments provide the RaygunMessage object that is about to be sent. One use for this event handler is to add or modify any information on the RaygunMessage. Another use for this method is to identify exceptions that you never want to send to raygun, and if so, set e.Cancel = true to cancel the send.

Strip wrapper exceptions

If you have common outer exceptions that wrap a valuable inner exception which you'd prefer to group by, you can specify these by using the multi-parameter method:


In this case, if a TargetInvocationException occurs, it will be removed and replaced with the actual InnerException that was the cause. Note that HttpUnhandledException and TargetInvocationException are already added to the wrapper exception list; you do not have to add these manually. This method is useful if you have your own custom wrapper exceptions, or a framework is throwing exceptions using its own wrapper.

Unique (affected) user tracking

There is a property named User on RaygunClient which you can set to be the current user's ID or email address. This allows you to see the count of affected users for each error in the Raygun dashboard. If you provide an email address, and the user has an associated Gravatar, you will see their avatar in the error instance page.

Make sure to abide by any privacy policies that your company follows when using this feature.

Version numbering

By default, Raygun will send the assembly version of your project with each report. If you need to provide your own custom version value, you can do so by setting the ApplicationVersion property of the RaygunClient (in the format x.x.x.x where x is a positive integer).

Tags and custom data

When sending exceptions manually, you can also send an arbitrary list of tags (an array of strings), and a collection of custom data (a dictionary of any objects). This can be done using the various Send and SendInBackground method overloads.

Breadcrumbs let you provide logging points in your code that will be collected and sent along with any exception sent to Raygun. This lets you have a better understanding of the events that happened in the system that lead up to the exception.

To record a Breadcrumb you can use the RecordBreadcrumb(string message) method to record a breadcrumb with a custom message but other properties set to default. If you wish to customize the other properties such as Level, Category or attach CustomData to the Breadcrumb you can construct a Breadcrumb object your self and pass it to RecordBreadcrumb.

There are two settings related to Breadcrumbs in the RaygunSettings configuration, "breadcrumbsLevel" which can be set to Debug, Info, Warning, or Error and is the same as a log level in something like log4net and "breadcrumbsLocationRecordingEnabled" which when set to true will include the class and method where the breadcrumb was logged from. This has a performance cost associated with it so it is only recommended to be enabled when needed.

WebApi support

Do you also need WebApi Raygun support for your project? Simply install the Mindscape.Raygun4Net.WebApi NuGet package which will work happily with this MVC package. The WebApi package is able to send additional exceptions to Raygun that occur in WebApi projects and can only be detected in specific ways which the package will do for you.

Example JSON Data Filter

using System;
using System.Linq;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Mindscape.Raygun4Net.Filters;

public class RaygunJsonDataFilter : IRaygunDataFilter
  private const string FILTERED_VALUE = "[FILTERED]";

  public bool CanParse(string data)
    if (!string.IsNullOrEmpty(data))
      int index = data.TakeWhile(c => char.IsWhiteSpace(c)).Count();
      if (index < data.Length)
        if (data.ElementAt(index).Equals('{'))
          return true;
    return false;

  public string Filter(string data, IList<string> ignoredKeys)
      JObject jObject = JObject.Parse(data);

      FilterTokensRecursive(jObject.Children(), ignoredKeys);

      return jObject.ToString(Formatting.None, null);
      return null;

  private void FilterTokensRecursive(IEnumerable<JToken> tokens, IList<string> ignoredKeys)
    foreach (JToken token in tokens)
      if (token is JProperty)
        var property = token as JProperty;

        if (ShouldIgnore(property, ignoredKeys))
          property.Value = FILTERED_VALUE;
        else if (property.Value.Type == JTokenType.Object)
          FilterTokensRecursive(property.Value.Children(), ignoredKeys);

  private bool ShouldIgnore(JProperty property, IList<string> ignoredKeys)
    bool hasValue = property.Value.Type != JTokenType.Null;

    if (property.Value.Type == JTokenType.String)
      hasValue = !string.IsNullOrEmpty(property.Value.ToString());

    return hasValue && !string.IsNullOrEmpty(property.Name) && ignoredKeys.Any(f => f.Equals(property.Name, StringComparison.OrdinalIgnoreCase));
Product Compatible and additional computed target framework versions.
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Mindscape.Raygun4Net.Mvc:

Package Downloads

Simple log4net appender which logs to the raygun.io API from your MVC application.


Simple log4net appender which logs to the raygun.io API from your MVC application.


Package is deprecated, please use `Mindscape.Raygun4Net.Mvc` which is signed.


Simple log4net appender which logs to the raygun.io API from your MVC application.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
11.0.2 149 6/20/2024
11.0.0 617 6/9/2024
11.0.0-rc1 61 6/7/2024
11.0.0-pre3 48 5/30/2024
11.0.0-pre2 99 5/24/2024
11.0.0-pre1 76 5/23/2024
10.1.2 640 5/9/2024
10.1.2-pre-1 56 5/9/2024
10.1.1 809 3/27/2024
10.1.1-pre-1 88 3/20/2024
10.1.0 400 3/18/2024
10.1.0-pre-2 65 3/18/2024
10.1.0-pre-1 85 3/15/2024
10.0.0 172 3/13/2024
10.0.0-pre-6 65 3/12/2024
10.0.0-pre-5 65 3/12/2024
10.0.0-pre-4 103 2/23/2024
10.0.0-pre-2 77 2/23/2024
10.0.0-pre-1 78 2/22/2024
9.0.4 1,022 3/3/2024
9.0.4-pre-1 1,392 2/29/2024
9.0.3 228 2/27/2024
9.0.2 200 2/22/2024
9.0.2-pre-1 69 2/19/2024
9.0.1 414 2/8/2024
9.0.0-pre3 70 2/7/2024
9.0.0-pre-1 61 2/2/2024
8.3.0-pre1 293 1/26/2024
8.0.0 8,457 11/14/2023
8.0.0-pre-1 74 11/9/2023
7.1.0 1,198 10/9/2023
7.0.0 575 9/12/2023
6.0.3 9,878 6/14/2023
6.0.2 288 6/12/2023
5.13.0 164,340 4/21/2021
5.12.1 28,008 2/9/2021
5.12.0 16,053 12/6/2020
5.11.0 19,368 8/16/2020
5.10.3 21,408 6/29/2020
5.10.2 47,352 2/7/2020
5.10.1 22,310 12/4/2019
5.10.0 31,191 10/9/2019
5.9.0 14,477 9/16/2019
5.8.0 16,832 7/17/2019
5.7.0 97,385 4/11/2019
5.6.0 134,500 9/17/2018
5.6.0-beta1 2,696 4/4/2018
5.5.5 11,935 7/15/2018
5.5.2 119,544 10/24/2017
5.5.0 48,604 5/16/2017
5.4.1 19,170 3/30/2017
5.3.1 214,346 6/22/2016
5.3.0 114,773 2/11/2016
5.2.0 15,104 11/24/2015
5.1.1 61,550 9/9/2015
5.1.0 35,252 6/24/2015
5.0.2 15,254 5/15/2015
5.0.1 20,599 4/16/2015
5.0.0 7,687 3/9/2015
4.2.1 12,683 2/12/2015
4.2.0 13,602 1/14/2015
4.1.0 8,916 12/5/2014
4.0.1 4,833 10/31/2014
4.0.0 5,204 10/21/2014