The MVC framework: the ContentTypeAttribute attribute
Another short post on the features available on the MVC futures assembly…today, we’re going to take a look at the ContentTypeAttribute. This attribute is an action filter attribute and you can use it to setup the content type of the current response (ie, you can apply this attribute to an action method to influence the value of the ContentType property of the HttpResponseBase object). The constructor of the this type receives a string which identifies the content type of the response.
Internally, this action filter ends up overriding the OnResultExecuting and OnResultExecuted methods in order to set the HttpResponseBase’s ContentType property to the value you’ve passed to its constructor.
And that’s it. Keep tuned for more on the MVC…