in .NET

How to display wordpress posts on your asp.net website using C#?

With wordpress evolved as one of the most famous and stable blogging platform, most people prefer to have their blog to be in wordpress, no matter in which technology the rest of their website uses. In this tutorial I will explain, how you can show your wordpress posts on your .net website. This may be useful e.g. when you wish to show your top blog posts on the home page of your website.

In this tutorial, we will make use of wordpress feed system to import the top posts from our wodpress blog. The wordpress feeds can be accessed at

<your-wordpress-url>/?feed=rss2 in case permalinks are not enabled

Or

<your-wordpress-url>/feedĀ  in case permalinks are enabled on your wordpress site.

The key is to read this feed in our .NET application and parse it to display on our website.

To make it a reusable component, we will code it as a custom .net control so that it can be used anywhere else.

Step 1

Create a new windows class library project

Step 2

Create a new class called FeedReader and save it in a file named FeedReader.cs

Step 3: Make sure that following imports have been added at the top of the file.

 using System;
 using System.Collections.Generic;
 using System.Text;
 using System.Xml;
 using System.Data;

Write a Comment

Comment