setrtwitter.blogg.se

Rss feed reader in asp net
Rss feed reader in asp net









The WebAPI has a very simple job, since both the IPostService and the IFeedService have done the major part. Using (XmlWriter xmlWriter = XmlWriter.Create( Var posts = await _postsService.GetPosts() STEP 1: Fetch Posts from the DataSource public async Task GetFeedDocument(string host) if (posts != null & posts.Count() > 0)įinally we’ll extract the completed XML document out of the StringWriter instance, on which the RssFeedWriter has been writing onto. We’ll use this Method on all the Post objects we’ve obtained and add them to the RssFeedWriter. New SyndicationPerson(post.Author, post.AuthorEmail)) If (!string.IsNullOrEmpty(post.Category)) This is done as below: private AtomEntry ToRssItem(Post post, string host) We’ll create an AtomEntry object for every Post which comes with similar fields such as Title, Description and so on. Like I said before, we need to first convert our Post object into equivalent RSS Feed object which is as per the schema. The Step 3 is to add the Post objects to this XML. This.AuthorEmail = Guid PostId ))Īwait rss.WriteDescription("My Blog is the Best one out there!") FeedController – Responsible for exposing the RSS feed endpoint, a simple GET call to /api/feed/rss would return an XML responsible which can be digested by any RSS client.īy the way, the Post class which represents a single Post object looks like below: namespace RssFeedApi.Models.IFeedService – Responsible for encapsulating the feed logic, which accepts a set of Post objects and returns an XML document string representing the RSS feed.IPostService – Responsible for encapsulating the data logic, which returns a set of Post objects for a given query.We shall break our total functionality into three components which will be responsible for its own sub problems. The goal is simple: the API pulls out data from the database for a set of Post objects, which the API would process and construct an RSS feed for consumption by the clients. Let’s start by creating a new WebAPI project which runs our endpoint for RSS feed. In this article, let’s build a simple endpoint in our ASP.NET Core WebAPI which can return RSS feed from a Posts database. While the terminology might seem alien to us, but at its core its just a web service which returns data from its data source in a predefined XML schema called as RSS. RSS feed works on XML, and so any website that exposes RSS feed returns content in XML making it a common medium for the RSS clients to work on.

rss feed reader in asp net

This way users don’t need to go check each and every website for new content.

rss feed reader in asp net

The best example for this is a news aggregator application, which brings in news articles from more than one news websites and regularly checks for new content and updates whenever new content is available. It is a web feed mechanism, which helps applications or clients get updated content from websites in a timely fashion and empower applications to get content from more than one website regularly without having to manually check for new content. RSS stands for "Really Simple Syndication".











Rss feed reader in asp net