I'm currently wondering about the prefered way to build multi view layouts using ASP.NET MVC.
For example in angular-based SPAs, loading different views into a layout is pretty straightforward:
<div ui-view="header"></div>
<div ui-view="content"></div>
.state("home", {
views: {
"header": { templateUrl: "app/_header.html" }
...
However in MVC, there seem to be multiple ways to achieve something, but I'm extremely confused about what 'method' is originally intended for what purpose.
- @Html.RenderPartial() - renders a 'partial', defined by the parent
- @Html.Partial() - seems to be the same as above
- @RenderPage() - renders a 'page', defined by the parent
- @RenderSection() - renders a 'section' by id, section defined by 'body view'
For a common "header, body, footer, nav" layout, what is the prefered (or the right) method? Or is it just a question of personal preference?
/Views/Sharedfolder and inspect the scaffolded_Layout.cshtmlfile. I think this will give you a starting point. Depending on what you're going for, you can also look at_ViewStart- link is relatively "old" but still great/quick read. Hth. - EdSF