I am trying to assign a response filter in the MVC OnActionExecuting event to modify the html outputted by the ActionResult of a Sitecore controller rendering. This works fine with plain MVC. However, in Sitecore, assigning a stream to the Response.Filter throws System.Web.HttpException: Filtering is not allowed.
Has anyone successfully implemented this in Sitecore?
public class UpperCaseFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
filterContext.HttpContext.Response.Filter =
new UpperCaseFilterStream(filterContext.HttpContext.Response.Filter);
}
}