Raygun on Azure Website

cs101

Posted on
Jun 17 2014

Hello:

I have a .NET MVC5 app deployed to an Azure website that uses Raygun. Everything works great locally but any server side exceptions are not being reported by Raygun - JavaScript errors are getting logged so I know Raygun has been setup correctly.

Here is the relevant code:

[Golbal.asax]

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

[Web.config]

RaygunSettings apikey="[key]" mediumTrust="true"

Does anything else need to be done to make this work on an Azure web site? Thanks for your help!


Jason Fauchelle

Raygun

Posted on
Jun 17 2014

Hello

Thanks for contacting us. Here is what's most likely happening: MVC applications by default will have an instance of HandleErrorAttribute added to the global filters collection. What this does is detect all unhanded exceptions, and then displays a nice error message page to the user rather than the browser crash screen. Because of this, your Application_Error method does not get called, and so Raygun never gets a chance to send a message.

By default, this behaviour is different in dev and production environments which is why it would seem to work fine if you run the application locally.

We recommend that you grab the latest version (2.2.1) of Raygun4Net from NuGet. https://www.nuget.org/packages/Mindscape.Raygun4Net Then remove the Raygun sending code from your Application_Error method, and use the Raygun http module instead. The module can be setup in web.config as follows:

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

Or

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

We've made recent changes to the module (which are now in version 2.2.1) specifically related to detecting the MVC HandleErrorAttribute and working nicely with it automatically.

Please let me know if you have questions about any of this.

-Jason Fauchelle


Christian

Posted on
Sep 25 2014

I still don't get any mvc-errors in Raygun after deploying it to Azure? (It works fine in development)

I'm using Raygun4Net 3.3.2 and added the module to system.webserver


BF

Posted on
Jan 26 2017

I am having the same issue. I have the following configuration: I see HTTPExceptions reported when hosted in Azure websites, but not other unhandled runtime exceptions. I do, however, see the correct behavior when running localhost. Is there something else needed when hosting in Azure Website?


Skiltz

Posted on
Aug 01 2017

I have the same issue. Unhandled exceptions not showing in Raygun. Works fine on localhost and in deployment slot. Any ideas?


Reply