ASP.NET GlobalFilters, except this one page

If you are an ASP.NET web dev, you probably know about GlobalFilters.  You can apply an ActionFilter attribute globally.  It’s super useful for things like RequireHttps.  Unless you have one page that you want to exclude from that requirement.  Maybe you have AuthorizeAttribute sprinkled around because everything on your site is secure except, obviously, the login page.  Maybe, like me, you have a health check page that you want accessible via HTTP, while everything else is forced to HTTPS, or maybe there is some other use case.  At any rate, I found a good solution, implemented it, and then had to remove it because things took a different direction.  So, I am writing this mostly so I don’t forget about it, because it’s a pattern that I’ve wondered about before and never found a good answer.

Searching for what others have done in this case is actually a little difficult.  The terms for what you want to accomplish – filter, exclude, except – are all pretty generic.  The specific ASP.NET classes and fields are subjects of many unrelated articles, so that doesn’t really help.  Phil Haack has an interesting approach, but ultimately, I prefer declaring rules or exceptions inline as attributes. What I had adapted, before pulling it back out, was a nice approach outlined by Ori Calvo.

If you need to implement a similar setup, check out both approaches, and see if one of them will work for you!


0 Responses to “ASP.NET GlobalFilters, except this one page”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


June 2017
« Jun    


I would like to thank Mike Hellrich for hosting a couple redirects for me while I sort out my web server problems.

%d bloggers like this: