I had a field in my database with SEO tags already HTML encoded-content: Thunder & Lightning, "very, very, scary" read up, the correct way to add a meta tag on the page
in c # (and therefore the razor in Umbraco) goes a little like this: 1: page = HttpContext.Current.Handler as page; 2: HtmlMeta meta description = new HtmlMeta (); 3: metaDescription.Name = "Description"; 4. meta description Content = "my description"; 5: page.Header.Controls.Add (meta description); That worked, but I found this was for output to the Web browser: Thunder & amp; Lightning & quot; very, very, scary & quot;ASP.NET seems to be HTML encoding to a string that is already HTML encoded, resulting in the above mess.Could not find an obvious way to stop the above code from performing unnecessary HTML coding, so screw makes it properly ... here's my working solution:
1: page = HttpContext.Current.Handler as page; 2: LiteralControl litMetaDescription = new LiteralControl (); 3: litMetaDescription .text = " "); 4: page.Header.Controls.Add (litMetaDescription); If you are sure that you pass the string is properly HTML encoded, above will work fine.
No comments:
Post a Comment