Topic:   Validating FEED Errors
Jan 28, 2021 15:18 1 Replies 703 Views DIVYA

I am using the following code from this page: https://itq.eu/knowledge/generating-rss-feed-asp-net-webpages/

@{
    Layout = null;

    var ContentType = "application/rss+xml";
    var sourceUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);

    // This is one of the things you have to do yourself ;-)
    var items = SomeSite.Net.Code.Blog.GetPosts(5);

    var feedItems = items.Select(p => new System.ServiceModel.Syndication.SyndicationItem(p.Title, p.Body, new Uri(string.Format("{0}/post/{1}", sourceUrl, p.Slug)))
    {
        PublishDate = new DateTimeOffset(p.CreateDate)
    });

    var feed = new System.ServiceModel.Syndication.SyndicationFeed(feedItems)
    {
        Title = new System.ServiceModel.Syndication.TextSyndicationContent("SomeSite.Net", System.ServiceModel.Syndication.TextSyndicationContentKind.Html),
        Description = new System.ServiceModel.Syndication.TextSyndicationContent("A description of SomeSite.Net")
    };

    using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(this.Response.OutputStream))
    {
        feed.GetRss20Formatter().WriteTo(writer);
    }

    this.Response.ContentType = ContentType;
}

But when I validate the page I receive the following errors:

This feed does not validate.

  • column 4108: Missing channel element: link [help]

    ... Oct 2020 17:10:34 -0700
                                                 ^

In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendations.

  • column 39: Avoid Namespace Prefix: a10 [help]

    help]

     

    ... ue, 06 Oct 2020 17:59:32 -0700help]

     

Prev Next
Topic Replies (1)
  1. 1
    idnkx user

    PARTH

    The solutions are as follows -

    1. add between and
    2. you cannot use a10
    3. you have missed guid element in
    4. add link with rel="self"

    example - public SyndicationItem(string title, SyndicationContent content, Uri itemAlternateLink, string id, DateTimeOffset lastUpdatedTime);

Leave a Reply
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect