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

Popular posts from this blog

command line - Use qwinsta in PowerShell ISE -

java - Incorrect order of records in M-M relationship in hibernate -

Python website log in: BIG-IP can not find session information in the request -