title: ASP.NET MVC 4 and Razor 2: View engine no longer supports xml?
body: <p>We had a view (.cshtml) which rendered XML for an RSS feed using ASP.NET MVC 3, which worked fine. Now that we have upgraded to ASP.NET MVC 4 with Razor 2 it's generating compile errors, similar to the below.</p>
  
  <pre><code>Parser Error
  
  Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
  
  Parser Error Message: Encountered end tag "item" with no matching start tag.  Are your start/end tags properly balanced?
  </code></pre>
  
  <p>The tags are properly balanced.</p>
  
  <p>Anyone have any thoughts?</p>
  
  <p><strong>UPDATE:</strong> I've isolated it down the the <strong>link</strong> element within the <strong>item</strong> element within the @foreach (...) { ... } block.</p>
  
  <pre><code>@foreach (var item in Model.Items)
  {
  &lt;item&gt;
      &lt;title&gt;@item.Title&lt;/title&gt;
      &lt;link&gt;@item.Link&lt;/link&gt;
      &lt;description&gt;@item.Description&lt;/description&gt;
      &lt;guid&gt;@item.Guid&lt;/guid&gt;
      @if (item.PublishedDateUtc.HasValue)
      {
      &lt;pubDate&gt;@item.PublishedDateUtc.Value.ToString("ddd, dd MMM yyyy HH:mm:ss") GMT&lt;/pubDate&gt;
      }  
  &lt;/item&gt;      
  }
  </code></pre>
  
  <p>I fixed it by doing using <strong>@Html.Raw</strong> the below.</p>
  
  <pre><code>@foreach (var item in Model.Items)
  {
  &lt;item&gt;
      &lt;title&gt;@item.Title&lt;/title&gt;
      @Html.Raw(string.Format("&lt;link&gt;{0}&lt;/link&gt;", item.Link.ToHtmlEncoded()))
      &lt;description&gt;@item.Description&lt;/description&gt;
      &lt;guid&gt;@item.Guid&lt;/guid&gt;
      @if (item.PublishedDateUtc.HasValue)
      {
      &lt;pubDate&gt;@item.PublishedDateUtc.Value.ToString("ddd, dd MMM yyyy HH:mm:ss") GMT&lt;/pubDate&gt;
      }  
  &lt;/item&gt;      
  }
  </code></pre>
  
  <p>Anyone have any better suggestions? Obviously, I could just use a class to declare model and return the XML directly from the controller, but I'm more interested in why this behavior occurs and what I can do to conform better to the Razor syntax.</p>