Transformation Filters
Transformation Filters allow you to manipulate the stream of data that defines a generated page before it is sent to the client.
Using Transformation Filters
Right before a generated page is streamed to the client, you can use a Transformation Filter to manipulate the stream. The Transformation Filter is applied after the view engine has built the page. Your view engine is not used with a Transformation Filter.
To assign a Transformation Filter to an action, use the TransformationFilter attribute.
public class UserController : Controller { [TransformationFilter(typeof(UpperCaseTransformationFilter))] public void View() { } }
In the example above, the entire page generated by the View action will be converted to upper case text.
You may apply multiple Transformation Filters to an action. To control their order of execution, use the ExecutionOrder property.
public class UserController : Controller { [TransformFilter(typeof(WikiTransformFilter), ExecutionOrder=1), TransformFilter(typeof(UpperCaseTransformFilter), ExecutionOrder=2)] public void View() { } }
In the example above, the page generated by the View action will first be transformed using the WikiTransformFilter and then the result of that will be transformed to upper case text.
You can create your own Transformation Filters by inheriting from the TransformFilter abstract base class.