I am using the popular Elmah.MVC error logging NuGet package. So I can navigate to /elmah to view my error logs. I have the following IgnoreRoute statements, so that MVC ignores the /elmah route:
routes.IgnoreRoute("elmah");
routes.IgnoreRoute("elmah/{*pathinfo}");
I have written the following authorization filter. How can I stop the filter below from executing when I navigate to /elmah. Surely there must be some way for it to respect the routes I tell it to ignore?
public class MyFilterAttribute : FilterAttribute, IAuthorizationFilter
{
public void OnAuthorization(AuthorizationContext filterContext)
{
// I don't want /elmah routes to execute this.
}
}
The solution was to check the ControllerName that was executing and if it is Elmah, we return and ignore this request.