title: ASP.NET Core should not encode attribute value in TagBuilder when rendering Json+Ld script
body: <p>I wrote an HtmlHelper extension to render Json+Ld script tags.
  The reason why I ask you for help is, the type attribute value &quot;application/ld+json&quot; is encoded and looks like &quot;application/ld+json&quot; and I could found a solution.</p>
  <p>My C# code of the HtmlHelper:</p>
  <pre><code>    public static IHtmlContent GetJsonLdScriptTag(this IHtmlHelper helper, string innerText)
      {
          //if(string.IsNullOrEmpty(innerText))
          //    return HtmlString.Empty;
  
          var tag = new TagBuilder(&quot;script&quot;);
          tag.MergeAttribute(&quot;type&quot;, &quot;application/ld+json&quot;);
  
          tag.InnerHtml.AppendHtml(innerText);
          tag.TagRenderMode = TagRenderMode.Normal;
  
          return tag;
      }
  </code></pre>
  <p>In my view I use call the Html extension so:</p>
  <pre><code>    @Html.GetJsonLdScriptTag(&quot;&quot;)
  </code></pre>
  <p>Html output is:</p>
  <pre><code>&lt;script type=&quot;application/ld&amp;#x2B;json&quot;&gt;&lt;/script&gt;
  </code></pre>
  <p>I tried to decode by using <strong>HtmlDecode(...)</strong> and with returning <strong>Html.Raw(...)</strong>;, but without success.</p>
  <p>Another try was to return string instead IHtmlContent object, but this failed also.</p>
  <pre><code>    public static string GetJsonLdScriptTag(this IHtmlHelper helper, string innerText)
      {
          //if(string.IsNullOrEmpty(innerText))
          //    return HtmlString.Empty;
  
          var tag = new TagBuilder(&quot;script&quot;);
          tag.MergeAttribute(&quot;type&quot;, &quot;application/ld+json&quot;);
  
          tag.InnerHtml.AppendHtml(innerText);
          tag.TagRenderMode = TagRenderMode.Normal;
  
          return tag.ToHtmlString();
      }
  
      public static string ToHtmlString(this IHtmlContent content)
      {
          using var writer = new IO.StringWriter();
          content.WriteTo(writer, HtmlEncoder.Default);
          return writer.ToString();
      }
  </code></pre>
  <p>Do you have an idea to handle this issue without hacks?</p>
  <p>Best Tino</p>