API Reference: MediaTypeAttribute Class

The MediaTypeAttribute can be applied to page content models. The attribute specifies the media (MIME) type value that is written in the Content-Type HTTP response header for server-side rendered pages. Redakt does not validate if the response is actually of the specified content type. It is your own responsibility to return content of the correct content type in the response. This can be done in the view.

If MediaTypeAttribute is not set on a page content model, text/html will be returned as the default media type in the HTTP response.

This attribute has no effect on responses from the Content Delivery API.

Usage

Decorate the page content model class with the MediaTypeAttribute. Pass the media type value in the attribute constructor. The attribute is not inherited, so if a media type is specified on a base class, it will not be automatically set on derived classes. Redakt does not check if the media type is a known valid media type.

Example

The following example sets the RSS media type for this page model.

[Page]
[MediaType("application/rss+xml")]
public class RssFeed: IContentType
{
    // ...
}