Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The "RenderBody" method has not been called for layout page "~/Views/Shared/index.cshtml"

The "RenderBody" method has not been called for layout page "~/Views/Shared/index.cshtml"

An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

how to fix this error

like image 527
asif Avatar asked Sep 03 '16 16:09

asif


1 Answers

In my case after I add

<div class="container body-content">
    @RenderBody()
    <hr />
    <footer><p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
    </footer>
</div>

to the shared layout's footer, all worked perfectly. this occurs because of the layout page on

view -> shared

haven't load the method @RenderBody() so you can either get rid of this using the upper code fragment or you can just comment the layout at the top of your relevant cshtml page.

like image 52
Tharusha Avatar answered Sep 21 '22 21:09

Tharusha