You can do this using sections. Go to your _Layout.cshtml and add a new section called head as follows:
<head> <meta charset="utf-8" /> <title>@ViewBag.Title</title> <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /> @RenderSection("head", false) </head>
A new section is added using @RenderSection. Now in your individual views, you can add content to your head as follows:
@section head { <script type="text/javascript""> </script> }
When the full view is displayed, javascript will be displayed in the chapter section just below the link tag. You can put something there. For example, meta tags.
Kevin junghans
source share