@RenderBody() vs @RenderSection()
RenderBody() must be available in Layout view i.e. it is mandatory for Layout view
RenderBody() does not take any parameter. A @RenderBody() in Layout page look like this –
RenderSection() method is optional.
RenderSection() takes the parameter as section name and a boolean parameter which is optional.
The first parameter is of string type which is the name of the section i.e. in layout pages, renders the content of a named section.
The second parameter is of a boolean type which says – In layout pages, renders the content of a named section and specifies whether the section is required.
A RenderSection() method look like this –
@RenderSection(“sectioname1”, required: true)
You can read other blogs on MVC here.
Next blog on MVC
- What is View?
- What is Controller in MVC?
- Anti-forgery tokens in MVC
- Data Annotation in MVC
- What is ViewModel?
- How to Pass data from Controller to View?