Reputation: 14176
No matter what I do I keep getting the following error:
The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "body".
I keep cutting-out pieces, but I am not sure how much simpler I can make it. Any help is appreciated.
MY VIEW START LOOKS LIKE:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
MY LAYOUT LOOKS LIKE:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- iOS web-app metas : hides Safari UI Components and Changes Status Bar Appearance -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>@ViewBag.Title - My ASP.NET Application</title>
<!-- CSS -->
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
<!-- WEB FONTS -->
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,300,400,700" />
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Oswald" />
<!-- FONTS -->
<link href="~/Content/font-awesome.min.css" rel="stylesheet" />
<!-- HEAD -->
@RenderSection("head", required: false)
</head>
<body>
<!-- BODY -->
<div id="main" role="main">
@RenderBody()
</div>
<!-- PAGE SCRIPTS -->
@RenderSection("scripts", required: false)
</body>
</html>
MY INDEX LOOKS LIKE:
HELLO WORLD
Upvotes: 0
Views: 275
Reputation: 6389
The body is not a section. Simply remove the "@section body" and curly braces and you're good to go!
Are you sure you don't have this anywhere on your layout page?
@RenderSection("body", required: true)
Upvotes: 1