The following sections have been defined but have not been rendered for the layout page

前端 未结 5 835
故里飘歌
故里飘歌 2021-02-03 18:13

This is an ASP.NET MVC 3 exception message. What it says? What should I do?

OK, I have this code:

@{
     Layout = \"~/_Layout.cshtml\";
     Page.Title          


        
5条回答
  •  庸人自扰
    2021-02-03 18:25

    I faced a similar problem where the layout template indeed has the @RenderSection(...) but inside an if-else statement. So when the page executes the statement that doesn't contain the @RenderSection it will throw that exception. If that is your case, then your solution is a little more complicated, either:

    • make sure you have @RenderSection outside of the statements or
    • repeat @RenderSection in both if-else statements, or
    • use different partial views, or
    • redesign the layout.

    That could be your main problem!

提交回复
热议问题