AllowLayoutAttribute Class

AllowLayoutAttribute Class

Specifies a layout that can be selected for this page view model.

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public sealed class AllowLayoutAttribute: Attribute, IPageModelAttribute

Inheritance  Attribute AllowLayoutAttribute

Implements  IPageModelAttribute

Constructors

Name Description
AllowLayoutAttribute() Specifies the layout that can be selected for this page view model by providing either a layout name or layout view path through the appropriate property.
AllowLayoutAttribute(string) Specifies the layout that can be selected for this page view model by layout name. The layout name is the filename of the view without (.cshtml) extension and path, e.g. for a view with path '~/Views/ContentPage.cshtml' the layout name is 'ContentPage'. If the name causes conflicts with other views with the same name but a different view path, use the property with the parameterless constructor instead.

Properties

Name Description
Name Gets or sets the name of the layout that can be selected for this page view model. The layout name is the filename of the view without (.cshtml) extension and path, e.g. for a view with path '~/Views/ContentPage.cshtml' the layout name is 'ContentPage'. If the name causes conflicts with other views with the same name but a different view path, use the property instead. The layout name is case insensitive.
ViewPath Gets or sets the view path of the layout that can be selected for this page view model. Must be the relative path from the web content root, e.g. '~/Views/ContentPage.cshtml'. The view path is case insensitive.

Methods

Name Description
Apply(PageDefinition)