Retrieve list of Recent Posts Outside of BlogEngine App

Aug 5, 2009 at 9:58 PM


I am planning on incorporating BlogEngine.Net into our site.  Thus, we would have two separate applications, one for our main site, and the other for BlogEngine.Net.  When the user clicks on the link for the News/Blogs/Articles section, they would be taken to the BlogEngine.Net application.  I know that within the BlogEngine.Net app there is a nice widget for retreiving the most recent posts.  But does anyone have any examples of retreiving the most recents posts using the XML Provider from outside of the application.  I assume that we would just need to access the BlogEngine/App_Data/Posts folder and parse through them.  But I was wondering if there is a "best way" to do this.



Aug 6, 2009 at 1:00 PM
Edited Aug 6, 2009 at 1:01 PM

I think the better way is using the RSS feed to get the latest posts

Aug 6, 2009 at 3:20 PM
Edited Aug 6, 2009 at 3:21 PM

Definately the way to go.  I feel kind of stupid not thinking of that myself as I have done the exact thing you suggested on a different site! 

For anyone interested, I read the RSS feed using System.ServiceModel.Web and System.ServiceModel.Syndication

XmlReader reader = XmlReader.Create("http://localhost/news/syndication.axd");
SyndicationFeed feed = SyndicationFeed.Load(reader);
foreach (var item in feed.Items)
     Post post = new Post()
          Title = item.Title.Text,
          PublishedDate = item.PublishDate.DateTime,
          Url = item.Id


Dec 16, 2009 at 11:29 AM

I have an issue related to this...i think.

For security reasons only users logged in via windows authentications can view the problem there. Directly viewing syndication.axd in the browser - no problem.

Retrieving the feed in order to implement it in an existing website is an other matter.

I have an aspx-file that can retrieve the feed and pass it on as js (pure text) - but with windows authentication, the aspx apparently does not have the same rights as the user.

Any ideas?


Mar 28, 2010 at 7:24 AM

Brand new user here with this issue.  Here's how I was able to solve it after searching in a bunch of places.

First, credit where credit is due, and that's our very own nickolsen's post above, which got me on the right track for displaying the feed in a DataList control.

Next, the code in the PageLoad() event::

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Me.IsPostBack Then
            Dim rdr As System.Xml.XmlReader = System.Xml.XmlReader.Create("")
            Dim feed As System.ServiceModel.Syndication.SyndicationFeed = System.ServiceModel.Syndication.SyndicationFeed.Load(rdr)
            Dim rss2 As Rss20FeedFormatter = feed.GetRss20Formatter
            dlRSS.DataSource = rss2.Feed.Items
            ' Iterate through collection to help interogate Items when debugging.
            For Each itm As SyndicationItem In feed.Items
                Dim msg As String = itm.Title.Text & " | " & itm.Categories(0).Name & " | " & itm.Id
        End If
    End Sub

Now for the DataList in the .aspx page:

            <asp:DataList ID="dlRSS" runat="server">                
                    <div class="RSSTitle">
                        <asp:HyperLink ID="TitleLink" runat="server" NavigateUrl='<%# Eval("Links[0].Uri.AbsoluteUri") %>' Text='<%# Eval("Title.Text") %>'>
                    <div class="RSSSubtitle">
                        <asp:Label ID="SubtitleLabel" runat="server" Text='<%# Eval("Categories(0).Name") %>'></asp:Label>
                    <div class="RSSInfo">
                        <asp:Label ID="DateRSSedLabel" runat="server" Text='<%# Eval("PublishDate.DateTime","DateLine: {0:d} {0:t}") %>'>

I hope this helps someone else.