Automatic MvcExceptionFilter injeciton triggers an Exception if Error View is not found #921
Description
openedon May 23, 2018
Since AI 2.6 the MvcExceptionFilter is automatically injected into the global filters. This broke some of our Applications, because we don't rely on MVC ExceptionFilters to handle our Exceptions.
I identified the cause to be the base.OnException
call inside the Filter, which executes the default ExceptionHandling code.
https://github.com/Microsoft/ApplicationInsights-dotnet-server/blob/33696c0d09a3c6e93a690198a09bd49d84a63c58/Src/Web/Web.Shared.Net/Implementation/ExceptionHandlersInjector.cs#L100
I believe this is obtrusive and could be easily avoided by not handling the exception in the base class, but rather only logging it.
As an alternative, is there an opt-out option for not automatically injecting the Filter?
Our current workaround is by registering our own ExceptionFilter and rethrowing the Exception.
Repro Steps
- Create empty ASP.NET MVC 5 Application
- Add Microsoft.ApplicationInsights.Web Package
- Turn customErrors mode="On"
- Create a HomeController and throw an Exception in Index()
- View Exception details in EventViewer or other Logging Framework
Actual Behavior
Exception type: InvalidOperationException
Exception message: The view 'Error' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/Error.aspx
~/Views/Home/Error.ascx
~/Views/Shared/Error.aspx
~/Views/Shared/Error.ascx
~/Views/Home/Error.cshtml
~/Views/Home/Error.vbhtml
~/Views/Shared/Error.cshtml
~/Views/Shared/Error.vbhtml
Expected Behavior
The actually thrown exception should be logged.
Version Info
SDK Version : 2.6.1
.NET Version : 4.7.1
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) :
OS : SDK
Hosting Info (IIS/Azure WebApps/ etc) : IIS