Skip to content

Latest commit

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Snickler.RSSCore: ASPNETCore Middleware for generating RSS Feeds

NuGet

This library was created in order to provide a way to easily generate RSS feeds on the fly via an ASP.NET Core Middleware.

Targets

Currently supports:

  • ASPNET Core 1.1 (netstandard1.3)
  • ASPNET Core 2.x (netstandard2.0)

Getting Started

Add the NuGet package to your project(s). Utilize the namespaces: Snickler.RSSCore.Models, Snickler.RSSCore.Providers, and Snickler.RSSCore.Extensions.

Create an RSS Provider

Create a provider class that implements IRSSProvider and returns a list of RSSItem objects via the RetrieveSyndicationItems method.

publicclassSomeRSSProvider:IRSSProvider{publicTask<IList<RSSItem>>RetrieveSyndicationItems(){IList<RSSItem>syndicationList=newList<RSSItem>();varsynd1=newRSSItem("Sample Title 1","Sample Content 1"){PermaLink=newUri("http://www.sampleaddress.com/sample-content-1"),LinkUri=newUri("http://www.sampleaddress.com/sample-content-1"),LastUpdated=DateTime.Now,PublishDate=DateTime.Now,Categories=newList<string>{".NET"},Authors=newList<string>{"someuser@sampleaddress.com"}};syndicationList.Add(synd1);returnTask.FromResult(syndicationList);}}

RSS Feed Configuration

Add your provider to the service registration in ConfigureServices with the AddRSSFeed extension

publicvoidConfigureServices(IServiceCollectionservices){services.AddRSSFeed<SomeRSSProvider>();services.AddMvc();}

Set the options for your RSS Feed in Configure with UseRSSFeed

publicvoidConfigure(IApplicationBuilderapp,IHostingEnvironmentenv){app.UseRssFeed("/feed",newRSSFeedOptions{Title="Snickler's Super Awesome RSS Feed",Copyright="2018",Description="The Best and Most Awesome RSS Feed Content",ManagingEditor="managingeditor@someaddress.com",Webmaster="webmaster@someaddress.com",Url=newUri("http://someaddress.com")});}

Optional RSS Caching Configuration

By default, MemoryCache is used to cache the feed for 1 day. To be able to update the cache duration or cache key, add a new instance of the MemoryCacheProvider to the Caching property within the RSSFeedOptions class.

app.UseRssFeed("/feed",newRSSFeedOptions{Title="Snickler's Super Awesome RSS Feed",Copyright="2018",Description="The Best and Most Awesome RSS Feed Content",ManagingEditor="managingeditor@someaddress.com",Webmaster="webmaster@someaddress.com",Url=newUri("http://someaddress.com"),Caching=newMemoryCacheProvider{CacheDuration=TimeSpan.FromDays(5),CacheKey="SomeSuperAwesomeCacheKey"}});

With this example setup, you'll be able to access the feed at http://whateverurl.com/feed

Example Project

An example project is located within the .sln file in the source.

About

ASPNETCore Middleware for generating RSS Feeds

Topics

Resources

Stars

8 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages