This library was created in order to provide a way to easily generate RSS feeds on the fly via an ASP.NET Core Middleware.
Currently supports:
- ASPNET Core 1.1 (netstandard1.3)
- ASPNET Core 2.x (netstandard2.0)
Add the NuGet package to your project(s). Utilize the namespaces: Snickler.RSSCore.Models, Snickler.RSSCore.Providers, and Snickler.RSSCore.Extensions.
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);}}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")});}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
An example project is located within the .sln file in the source.