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:
- Inherit from the
RazorPageTemplate
. - Set the
TemplateId
(GUID) andTemplateTitle
(string) properties within theConfigure
method override. - Declare one
XhtmlDocument
property with aPlaceholder
attribute on it. (It will serve as a standard C1 CMS content placeholder.) - 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.