title: MVC 5 Render View to String
body: <p>It seems, most code for rendering view into string doesn't work in MVC 5.</p>
  
  <p>I have latest MVC 5.1.2 templates and I am trying to render view into string.</p>
  
  <pre><code>    public static String RenderViewToString(ControllerContext context, String viewPath, object model = null)
      {
          context.Controller.ViewData.Model = model;
          using (var sw = new StringWriter())
          {
              var viewResult = ViewEngines.Engines.FindView(context, viewPath, null);
              var viewContext = new ViewContext(context, viewResult.View, context.Controller.ViewData, context.Controller.TempData, sw);
              viewResult.View.Render(viewContext, sw);
              viewResult.ViewEngine.ReleaseView(context, viewResult.View);
              return sw.GetStringBuilder().ToString();
          }
      }
  </code></pre>
  
  <p>Well, it's working but its output contains lots of $ marks instead tags. I read something about it was fixed in RC version, but that's old news.</p>
  
  <p>Problem looks like this</p>
  
  <pre><code>&lt;$A$&gt;&lt;h1&gt;&lt;/h1&gt; 
  &lt;table&lt;/$A$&gt;&lt;$B$&gt; class=""&lt;/$B$&gt;&lt;$C$&gt;&gt; &lt;tbody&lt;/$C$&gt;&lt;$D$&gt;&lt;/$D$&gt;&lt;$E$&gt;&gt;&lt;/tbody&gt;
  &lt;/table&gt;&lt;/$E$&gt;
  </code></pre>
  
  <p>I would like to ask, how do you render views into string in latest MVC 5 template ?
  Thanks.</p>