I have a razor helper that is meant to create a meta tag on the fly, however all I am seeing in the source of the page are asci characters.. the page source should read <meta name='robots' content='noindex' />
Much appreciate all replies and suggestions. Thank you!
Helper -
@helper WriteMetaRobots(DynamicNode siteRoot)
{
var robotValue = "noindex";
var robots = !string.IsNullOrEmpty(CurrentModel.GetPropertyValue("metaRobots")) ? "<meta name='robots' content='"+robotValue+"' />" : "";
@robots
}
Page source -
<meta name='robots' content=noindex />
Razor encodes html to prevents xss attacks. So you'll have to explicity tell razor not to encode the html tags. Instead of @robots
you'll want to use @Html.Raw(robots)
here
More information about xss prevention can be found here