Instead of partial viewing, you can go to master / sub layouts.
MasterLayout.cshtml
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>@ViewBag.Title</title> </head> <body> @RenderBody() </body> </html>
Layout.cshtml
@{ Layout = "~/Views/Shared/_MasterLayout.cshtml"; } // html code above render body @RenderBody() // html code below render body
Your Layout.cshtml ( Layout.cshtml ) contains the code, which should be in a partial view.
source share