Bare-Bones Razor Template

Turn a CSHTML file into a Razor page template

For the a Razor Web Page (.cshtml file) to serve a standard C1 CMS Page template, you should put it in ~/App_Data/PageTemplates and it must at least:

  1. Inherit from the RazorPageTemplate.
  2. Set the TemplateId (GUID) and TemplateTitle (string) properties within the Configure method override.
  3. Declare one XhtmlDocument property with a Placeholder attribute on it. (It will serve as a standard C1 CMS content placeholder.)
  4. Call the Markup helper method to render the placeholder property passed as a input parameter.
@inherits RazorPageTemplate

@functions {
    public override void Configure()
    {
        TemplateId = new Guid("bed582d3-d604-4858-a3a7-5b01d39d11e1");
        TemplateTitle = "My First Razor Template";
    }

    [Placeholder(Id = "content", Title = "Content", IsDefault = true)]
    public XhtmlDocument Content { get; set; }

}
<!DOCTYPE html>
<html>
<head></head>
<body>
    @Markup(Content)
</body>
</html>

The above is enough to get a "bare-bones" Razor page template in C1 CMS.