title: ASP.NET MVC render partial view to a string to return with JSON
body: <p>So i have a finished method that works and i use it all over the website:</p>
  
  <pre><code>public PartialViewResult GetBlogEntries(int itemsToTake = 5)
  {
      ...
      return PartialView("_BlogPost", model);
  }
  </code></pre>
  
  <p>Now i want to get this from my javascript in JSON form.</p>
  
  <pre><code>public JsonResult GetBlogPostJson()
  {      
      var blogEntry = GetBlogEntries(1);
      var lastEntryId = GetLastBlogEntryId();
      return Json(new {Html = blogEntry, LastEntryId = lastEntryId}, JsonRequestBehavior.AllowGet);
  }
  </code></pre>
  
  <p>Idea is to get it like this:</p>
  
  <pre><code>$.ajax({
              url: '/Blog/GetBlogPostJson',
              dataType: 'json',
              success: function (data) {
                  var lastEntryId = data.LastEntryId;
                  var html = data.Html;
                  ...
              }
          }); 
  </code></pre>
  
  <p>Problem is that this of course do not produce a string, but a PartialViewResult.</p>
  
  <p>Question is, how can i resolve the PartialViewResult into html that i can send back with JSON ?</p>