Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8062651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:44:27+00:00 2026-06-05T10:44:27+00:00

We had a view (.cshtml) which rendered XML for an RSS feed using ASP.NET

  • 0

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.

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?

The tags are properly balanced.

Anyone have any thoughts?

UPDATE: I’ve isolated it down the the link element within the item element within the @foreach (…) { … } block.

@foreach (var item in Model.Items)
{
<item>
    <title>@item.Title</title>
    <link>@item.Link</link>
    <description>@item.Description</description>
    <guid>@item.Guid</guid>
    @if (item.PublishedDateUtc.HasValue)
    {
    <pubDate>@item.PublishedDateUtc.Value.ToString("ddd, dd MMM yyyy HH:mm:ss") GMT</pubDate>
    }  
</item>      
}

I fixed it by doing using @Html.Raw the below.

@foreach (var item in Model.Items)
{
<item>
    <title>@item.Title</title>
    @Html.Raw(string.Format("<link>{0}</link>", item.Link.ToHtmlEncoded()))
    <description>@item.Description</description>
    <guid>@item.Guid</guid>
    @if (item.PublishedDateUtc.HasValue)
    {
    <pubDate>@item.PublishedDateUtc.Value.ToString("ddd, dd MMM yyyy HH:mm:ss") GMT</pubDate>
    }  
</item>      
}

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:44:28+00:00Added an answer on June 5, 2026 at 10:44 am

    When I first glanced at this I noticed your link tag had a closing tag instead of self closing. Razor is smart enough to know html and knows how the link tag is closed. Here is another example of something that could break to show how Razor reads html.

    ....
    <tbody>
        @if (alternating) {
            <tr class='alternating'>
        } else {
            <tr>
        }
    
        ....
    
            </tr>
    </tbody>
    

    This will fail because it sees a </tr> without an opening tag.

    Tags that are always self closing are interpreted by Razor to be self closing. so your link tag actually ended at the >. (since it’s valid html to have a self closing tag without a />) So now we come across a closing tag with no opening tag to justify it so the parser gives up and says that it’s not properly formatted. I’d have to do some checking but I’m pretty sure it assumes the closing link tag was meant for the item tag since that would give proper balance which is why the rest of the file parses fine until it comes across this lone item tag with no opening tag.

    It should be smart enough to know that the previous closing tag wasn’t the right one. It might be an issue to take up with the team.

    I haven’t tried it but you should be able to do this

    @foreach (var item in Model.Items)
    {
    <item>
        <title>@item.Title</title>
        @:<link>
            @item.Link
        @:</link>
        <description>@item.Description</description>
        <guid>@item.Guid</guid>
        @if (item.PublishedDateUtc.HasValue)
        {
        <pubDate>@item.PublishedDateUtc.Value.ToString("ddd, dd MMM yyyy HH:mm:ss") GMT</pubDate>
        }  
    </item>      
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to add a partial view using asp.net mvc 3 and razor
I use templated helpers in an ASP.NET MVC 3 project. One display template had
I'm using ASP.NET MVC 3 (Razor) and have created a Controller named Controllers -
Had a problem with the recursive conflictCheck() method. That seems fine now. I have
I had grid view which retrieved data from database and mad update for specific
I had grid view which bind sql data source and added field to update
I'm using a generic system for reporting which takes data from a database view
I'm experimenting with creating a plugin framework for ASP.NET MVC. I've managed to inject
I am working on an ASP.NET MVC application. For some reason, everytime I think
Has anyone had experience with calling a view using EF 4.1 DBContext object? If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.