Filtering is not allowed
Your code seems to be working for me when used in a brand new ASP.NET MVC 5 application created in VS2013 (the regular expressions may need to be adjusted, but that's a minor detail). I've uploaded a full solution here. Could you try it out?
To be clear, I noticed that you've tagged the question with asp.net-mvc-3 and asp.net-mvc-4, but I haven't had the opportunity to test on those version of ASP.NET MVC.
Try to add null-check before apply filter:
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var response = filterContext.HttpContext.Response;
if (response.Filter == null) return; // <-----
response.Filter = new YourFilter(response.Filter);
}