Explain Sections is MVC?

Section are the part of HTML which is to be rendered in layout page. In Layout page we will use the below syntax for rendering the HTML –
@RenderSection("TestSection")
And in child pages we are defining these sections as shown below –
@section TestSection{
<h1>Test Content</h1> 
}
If any child page does not have this section defined then error will be thrown so to avoid that we can render the HTML like this –
@RenderSection("TestSection", required: false)

Comments

Popular posts from this blog

List out different return types of a controller action method?

3-6 yr Experience Interview Questions in .Net Technologies

Explain what is the difference between View and Partial View?