It seems to me the easiest way would be to define a section in the <head> tag of your layout file that you can choose to populate with data in your views
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title - My ASP.NET MVC Application</title>
<link href="https://stackoverflow.com/questions/20993317/~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
<!-- Adding a RenderSection here, mark it as not required-->
@RenderSection("AdditionalMeta", false)
@Styles.Render("~/Content/css")
</head>
Now, in any view in which you need to add additional meta data, simply add the following code at the end/beginning (after model declarations) of your view file
@section AdditionalMeta
{
<meta name="robots" content="noindex,nofollow"/>
}
Since all of the Razor stuff is processed server side, there would be no issues in a) having JS append items given that some crawlers do not implement JS and b)no late appending to <head> tag/etc. Also, being marked as not required means that you only have to update the pages that you want to not be indexed and not have to set a variable on every single page in your application.