Layouts in MVC

Layouts are used when there is a need to maintain a consistent look across multiple views.(Example : Header and footer across views).They are similar to master pages in ASP.NET.

Important Methods in Layouts :


1.Renders View and all of its components in layout page.

2.There can be only one RenderBody in a layout page.



1.Renders the specified page in layout.It takes an argument that specifies the location of page.


2.There can be multiple RenderPage method in layout.


Renders the content of page in specified region  in layout.


1.Requires name of the section.If not specified exception will be thrown.

2.IsRequired attribute in section method has to be set to false,if section is not mandatory for every view,else an exception will be thrown.








Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s