An RSS (Really Simple Syndication) feed is a file that contains content that a site has published. Usually in reverse chronological order. RSS feeds are a fantastic way for interested parties to embed, view and consume said site's latest content in many different ways.
Where is it?
You can access the feed by going to the following link: https://shanesmith.azurewebsites.net/Feed; This is the URL you can enter into your desired feed reader to set up a subscription to my blog. Alternatively, you can find the RSS feed icon on the footer of all pages across my site.
How you can use it?
To consume the RSS feed, you can utilise popular RSS feed reader services like Feeder or Feedly. Other services are available, and with a quick search, I am sure you can find one that suits your needs. You can even subscribe to an RSS feed within Outlook. Just follow this tutorial from Microsoft.
How I created the RSS feed?
As RSS formats are specified using a generic XML file, it's relatively easy to generate an HTTP request to return the latest posts and return a valid XML file that conforms to the RSS standards. Creating an RSS feed is even simpler for my application as it's built using .Net, meaning I have access to the following SyndicationFeed assembly to serialise my models to valid RSS 2.0 standards.
Below is an example that illustrates how I accomplished a simple RSS feed using the SyndicationFeed
assembly:
IQueryable<Post> latestPosts; // Omitted code to get posts from db; out-of-scope.
string url; // Omitted code to retrieve url; out-of-scope.
// Create the Feed
var feed = new SyndicationFeed("Latest Posts", "Shane's Blog RSS Feed",
new Uri(url),
Guid.NewGuid().ToString(),
DateTimeOffset.Now);
// Populate the Feed
var items = new List<SyndicationItem>();
foreach (var post in posts)
{
var postUrl = $"{url}/Posts/View?postId={post.Id}";
items.Add(new SyndicationItem(post.Title,
post.Abstract,
new Uri(postUrl),
post.Id.ToString(),
post.PublishedDate));
}
// Return the populated Feed
feed.Items = items;
return new RssActionResult { Feed = feed };
Comments
Be the first to comment!