Retrieving blog posts

Topics: Business Logic Layer
Apr 6, 2011 at 7:11 PM

I have a implementation and I want to display n number of most recent blog posts on a page within my site.  My question is, what is the best way to achieve this?  I realize that the blog exists but that is not a scalable solution.  I can't have my home page making an HTTP request, then parsing XML every time.  It would be much better if I had a List<BlogPosts> that are cached, and can then be retrieved through an API.  Ideally that list of objects would be updated every time (refetching from the DB is fine) someone posts a new entry.

Any thoughts?

Apr 7, 2011 at 11:25 AM

If your site and BE are part of the same application, then you can use the BE API to get the most recent posts.  You could use code like the following for example.

List<BlogEngine.Core.Post> posts = new List<Post>(BlogEngine.Core.Post.Posts);
for (int i = 0; i < Math.Min(5, posts.Count); i++)
	string title = posts[0].Title;
	string link = posts[0].RelativeLink;