title: Rendering html code using TagBuilder and ASP.NET MVC 4 (with Razor engine)
body: <p>I would like to render <code>li</code> items using TagBuilder.</p>
  
  <p>My function</p>
  
  <pre><code>public static string RenderListTag(this HtmlHelper helper, string labelText, string action, string controller, bool isAdmin, string listCssClass = "")
          {
              string value = string.Empty;
  
              TagBuilder li = new TagBuilder("li");
              TagBuilder anchor = new TagBuilder("a");
              UrlHelper urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);
  
              if (string.IsNullOrEmpty(action) || string.IsNullOrEmpty(controller))
              {
                  anchor.MergeAttribute("href", "#");
              }
              else
              {
                  anchor.MergeAttribute("href", urlHelper.Action(action, controller, new
                  {
                      area = isAdmin ? "Admin" : ""
                  }));
              }
  
              anchor.SetInnerText(labelText);
  
              if (action.IsEqualWith(helper.ViewContext.RouteData.Values["action"].ToString()))
              {
                  li.MergeAttribute("class", "active");
              }
  
              if (!string.IsNullOrEmpty(listCssClass))
              {
                  li.MergeAttribute("class", listCssClass);
              }
  
              li.SetInnerText(anchor.ToString(TagRenderMode.Normal));
  
              return li.ToString(TagRenderMode.Normal);
          }
  </code></pre>
  
  <p>When I call using the following code:</p>
  
  <pre><code>@Html.RenderListTag("Home", "Index", "Contents", false)
  @Html.RenderListTag("About", "About", "Home", false)
  @Html.RenderListTag("Contact", "Contact", "Home", false)
  @Html.RenderListTag("Show toolbar", "", "", false, "options no-display")
  @Html.RenderListTag("CMS", "Index", "Home", true)
  </code></pre>
  
  <p>The results is printed as text NOT html tag.</p>
  
  <pre><code>&lt;li class="active"&gt;&amp;lt;a href=&amp;quot;/Contents&amp;quot;&amp;gt;Home&amp;lt;/a&amp;gt;&lt;/li&gt; &lt;li&gt;&amp;lt;a href=&amp;quot;/Home/About&amp;quot;&amp;gt;About&amp;lt;/a&amp;gt;&lt;/li&gt; &lt;li&gt;&amp;lt;a href=&amp;quot;/Home/Contact&amp;quot;&amp;gt;Contact&amp;lt;/a&amp;gt;&lt;/li&gt; &lt;li class="options no-display"&gt;&amp;lt;a href=&amp;quot;#&amp;quot;&amp;gt;Show toolbar&amp;lt;/a&amp;gt;&lt;/li&gt; &lt;li class="active"&gt;&amp;lt;a href=&amp;quot;/Admin/Home&amp;quot;&amp;gt;CMS&amp;lt;/a&amp;gt;&lt;/li&gt; 
  </code></pre>
  
  <p>I want to print the HTML tag not text.</p>
  
  <p>Where is my mistake ?</p>