I have a custom attribute with the following code:
public override void OnException(ExceptionContext filterContext)
{
if (filterContext != null && filterContext.HttpContext != null && filterContext.Exception != null)
{
//If customError is Off, then AI HTTPModule will report the exception
if (filterContext.HttpContext.IsCustomErrorEnabled)
{
//Log to AI
}
}
base.OnException(filterContext);
}
So whenever an exception occurs, it runs through this attribute, which will log the exception in Application Insights.
My problem is that the base.OnException is redirecting to a default "Error" view, I deleted the default Error view that was located in /Shared/Error.cshtml, and created my own error view. How do I get it to redirect to my custom error view instead of the default one? Right now it is throwing view errors since it cannot find the default error view.
System.InvalidOperationException The view 'Error' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/Shared/Error.aspx ~/Views/Shared/Error.ascx ~/Views/Shared/Error.cshtml ~/Views/Shared/Error.vbhtml
Any insights to this would be greatly appreciated. Thanks!
Error.cshtml
– Reza Aghaei