c# - How to get ASP.NET MVC IAuthorizationFilter to respect IgnoreRoute's -
i using popular elmah.mvc error logging nuget package. can navigate /elmah view error logs. have following ignoreroute statements, mvc ignores /elmah route:
routes.ignoreroute("elmah"); routes.ignoreroute("elmah/{*pathinfo}");
i have written following authorization filter. how can stop filter below executing when navigate /elmah. surely there must way respect routes tell ignore?
public class myfilterattribute : filterattribute, iauthorizationfilter { public void onauthorization(authorizationcontext filtercontext) { // don't want /elmah routes execute this. } }
the solution check controllername executing , if elmah, return , ignore request.
public class myfilterattribute : filterattribute, iauthorizationfilter { public void onauthorization(authorizationcontext filtercontext) { // don't want /elmah routes execute filter. string controllername = filtercontext.actiondescriptor.controllerdescriptor.controllername; if (string.equals(controllername, "elmah", stringcomparison.ordinal)) { return; } } }
Comments
Post a Comment