RenderBody is the insertion point in a Razor layout for content unique to the current view. Shared markup stays in _Layout.cshtml; each view contributes the remaining, unsectioned markup at this call. section 22.4
The method is inherited from RazorPage<T>. A view selects the layout by assigning Layout = "_Layout"; the Razor engine searches the controller and Shared view folders for the matching file. section 22.4
Place view content inside shared markup
_Layout.cshtml can provide the document shell and call RenderBody where page-specific output belongs:\n\n<body>\n <h6>Shared View</h6>\n @RenderBody()\n</body>\n\nA view using Layout = "_Layout" can then contain only its own table or other page markup. Content declared with @section is different: RenderSection places that named fragment, while RenderBody receives everything else. section 22.4 section 22.4.4
Listing 22.9 The contents of the _Layout.cshtml file in the Views/Shared folder
<!DOCTYPE html> <html> <head> <link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet" /> </head> <body> <h6 class="bg-primary text-white text-center m-2 p-2">Shared View</h6> @RenderBody() </body> </html>
Inspect the complete layout listing to see RenderBody positioned between shared HTML elements. section 22.4

