Answered by:
RSS Feed Duplicates

Question
-
User-617274320 posted
I've searched and found several posts about setting up RSS Feeds and ended up using this one to create mine.
http://dotnetslackers.com/articles/aspnet/How-to-create-a-syndication-feed-for-your-website.aspx
It seems to be working fine, however when I add the RSS feed to my outlook or when I refresh using Google reader i get duplicates of the articles every time. I've made sure that I am setting both the LastUpdated and PublishDate which look correct but for some reason i still get duplicates everytime i refresh (or every time i refresh and wait 60 seconds). Help would be greatly appreciated.
Here's a temp link to the feed
http://tayloredcom.web709.discountasp.net/Feed.aspx?FeedType=RSS
And here's my code
Imports System.ServiceModel.Syndication Partial Class Feed Inherits System.Web.UI.Page Enum FeedType RSS Atom End Enum Private _CurrentFeedType As FeedType Public Property CurrentFeedType() As FeedType Get Return _CurrentFeedType End Get Set(value As FeedType) _CurrentFeedType = value End Set End Property Private Sub LoadFeedData() Dim oBlogs As New StingrayCMS.Content.Blog oBlogs.LoadAll() If oBlogs.HasError = True OrElse oBlogs.Count < 1 Then oBlogs.Dispose() Exit Sub End If 'Set Feed Type Select Case True Case Request.QueryString("FeedType") = "RSS" _CurrentFeedType = FeedType.RSS Response.ContentType = "application/rss+xml" Case Request.QueryString("FeedType") = "Atom" _CurrentFeedType = FeedType.Atom Response.ContentType = "application/atom+xml" Case Else 'Default to RSS _CurrentFeedType = FeedType.RSS Response.ContentType = "application/rss+xml" End Select 'Set Syndication Variables Dim sSyndicationTitle As String = "" Dim sSyndicationDescription As String = "" Dim sSyndicationLink As String = "" Dim sSyndicationCopyright As String = "" Dim sSyndicationAuthorEmail As String = "" Dim oSetting As New StingrayCMS.Content.Setting() oSetting.LoadBy(StingrayCMS.Content.Setting.LookupType.Name, "Syndication Title") If oSetting.HasError = False AndAlso oSetting.Count > 0 Then sSyndicationTitle = oSetting.Value End If oSetting.LoadBy(StingrayCMS.Content.Setting.LookupType.Name, "Syndication Description") If oSetting.HasError = False AndAlso oSetting.Count > 0 Then sSyndicationDescription = oSetting.Value End If oSetting.LoadBy(StingrayCMS.Content.Setting.LookupType.Name, "Syndication Copyright") If oSetting.HasError = False AndAlso oSetting.Count > 0 Then sSyndicationCopyright = oSetting.Value End If oSetting.LoadBy(StingrayCMS.Content.Setting.LookupType.Name, "Syndication Author Email") If oSetting.HasError = False AndAlso oSetting.Count > 0 Then sSyndicationAuthorEmail = oSetting.Value End If sSyndicationLink = ConfigurationManager.AppSettings("SyndicationLandingLink") oSetting.Dispose() 'Set Syndication Properties Dim oUtility As New StingrayCMS.Utilities.WebObject Dim oSyndicationFeed = New SyndicationFeed oSyndicationFeed.Title = TextSyndicationContent.CreatePlaintextContent(sSyndicationTitle) oSyndicationFeed.Description = TextSyndicationContent.CreatePlaintextContent(sSyndicationDescription) oSyndicationFeed.Links.Add(SyndicationLink.CreateAlternateLink(New Uri(sSyndicationLink))) oSyndicationFeed.Links.Add(SyndicationLink.CreateSelfLink(New Uri(oUtility.GetCurrentURLString))) oSyndicationFeed.Copyright = TextSyndicationContent.CreatePlaintextContent(sSyndicationCopyright) oSyndicationFeed.Language = "en-us" Dim lFeedList As New List(Of SyndicationItem) 'Create Feed For Each oBlog In oBlogs.BlogsAsList Dim oSyndicationItem As New SyndicationItem oSyndicationItem.Title = TextSyndicationContent.CreatePlaintextContent(oBlog.Title) oSyndicationItem.Links.Add(SyndicationLink.CreateAlternateLink(New Uri(ConfigurationManager.AppSettings("RootSitePath") & "/" & ConfigurationManager.AppSettings("BlogRewriteDirectory") & "/" & oBlog.SeoURL))) oSyndicationItem.Summary = TextSyndicationContent.CreatePlaintextContent(oBlog.PreviewText) oSyndicationItem.PublishDate = oBlog.DateStamp oSyndicationItem.LastUpdatedTime = oBlog.DateStamp 'Set Blog Categories oBlog.LoadBlogCategories() If oBlog.HasError = False AndAlso oBlog.BlogCategoryCount > 0 Then For Each oBlogCategory In oBlog.BlogCategoriesAsList oSyndicationItem.Categories.Add(New SyndicationCategory(oBlogCategory.Name)) Next End If 'Set Author Info Dim oSyndicationAuthor As New SyndicationPerson oSyndicationAuthor.Email = sSyndicationAuthorEmail oSyndicationAuthor.Name = oBlog.Author oSyndicationFeed.Authors.Add(oSyndicationAuthor) lFeedList.Add(oSyndicationItem) Next oSyndicationFeed.Items = lFeedList 'Write Feed Dim oFeedWriter As System.Xml.XmlWriter oFeedWriter = System.Xml.XmlWriter.Create(Response.OutputStream) Select Case _CurrentFeedType Case FeedType.RSS Dim oAtomFormatter As New Atom10FeedFormatter(oSyndicationFeed) oAtomFormatter.WriteTo(oFeedWriter) Case FeedType.Atom Dim oRssFormatter As New Rss20FeedFormatter(oSyndicationFeed) oRssFormatter.WriteTo(oFeedWriter) End Select oFeedWriter.Close() oBlogs.Dispose() End Sub Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load LoadFeedData() End Sub End Class
Tuesday, September 18, 2012 3:52 PM
Answers
-
User-617274320 posted
I found the fix, after reading this article
http://stackoverflow.com/questions/182615/why-does-my-rss-feed-duplicate-some-entries
it looks like I left out setting the SyndicationItem's ID property so it assigned a unique one each time. Now that I set the ID I am no longer getting dupes.
oSyndicationItem.Id = oBlog.ID
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 19, 2012 8:38 PM
All replies
-
User-1605278047 posted
can you check below links, might be useful to you.
Tuesday, September 18, 2012 4:11 PM -
User-617274320 posted
Not very helpfull....
Tuesday, September 18, 2012 4:16 PM -
User-1605278047 posted
I have gone throught the article you have shared. http://dotnetslackers.com/articles/aspnet/How-to-create-a-syndication-feed-for-your-website.aspx. if you check the comments, even the code on which you have created your RSS feed also facing the same problem.
Tuesday, September 18, 2012 4:45 PM -
User-617274320 posted
Yea I saw that. Since no one answered there and I found that link from this forum, I figured I'd try here for a solution.
Tuesday, September 18, 2012 4:58 PM -
User-617274320 posted
I found the fix, after reading this article
http://stackoverflow.com/questions/182615/why-does-my-rss-feed-duplicate-some-entries
it looks like I left out setting the SyndicationItem's ID property so it assigned a unique one each time. Now that I set the ID I am no longer getting dupes.
oSyndicationItem.Id = oBlog.ID
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 19, 2012 8:38 PM