Skip to content

Set default layout

simplic edited this page Feb 15, 2016 · 1 revision

Set default layout

To set the default layout you can use a view different methods.

Use the IronPyton api

To set the default layout for the current asp.net mvc application just call

aspnet.Views.set_layout('~/Views/Shared/_Layout.cshtml')

. The path in set_layout has to point to your layout file.

Use _ViewStart.cshtml

Create a file with the name _ViewStart.cshtml in your Views directory. This file has to look like this:

@inherits System.Web.Mvc.ViewStartPage

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

The path has to point to your layout file.

Use Layout attribute in a view

At the top of every .cshtml file you can specify the layout to use. Just set the layout attribute like this:

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

Clone this wiki locally