In the last TTT we had a session to discuss about several things regarding the .NET User Groups and one of the subjects was the MSDN forums.
Microsoft told us that they were investing some efforts to improve the Spanish MSDN forums and immediately after that we talked about the local forums each .NUG has in their sites. The idea proposed was to remove the local forums and to support the MSDN forums, this would benefit the developer community since instead of having microsites we can sum our efforts to have a centralized help site.
In Baleares on .NET we thought that the best was to have our own forums in order to provide better assistance to our community, we wanted to be sure that the .NET developers of Baleares had answers to their questions. Because of that some "volunteers" are monitoring the forums to provide solutions, but as the community grows we can give less support and the idea to post the questions to bigger communities does not seem to be a bad idea.
I must say that I'm not 100% convinced yet that this is best solution for our community, since I trust the "closeness" concept we tried to offer and that had good results until now.
Anyway I've decided to give a try and to introduce progressively some of the MSDN forums in order our users know them. I wanted not only to insert a simple link to the MSDN forums, but to display some of the posts in our website in line with the current appearance.
To do it, we can save lot of time taking profit of the Community Server platform to add the latest posts in our home page in the same way the Recent Post List appears. If we take a look about how CS displays the recent posts, we can see that it uses the control IndexPostList, which basically consists of display the results of a search done when the page inits. Below you can see the code the guys from CS use:
It doesn't seem too complicated, basically we need to introduce a new IndexPostList control in the main page and set the DataSource property with our own List of IndexPost. All the MSDN ES forums allow to syndicate the content, this means that we can access it via RSS. The easiest way to do this with .NET is to use a XmlTextReader and read the contents inside a DataSet.
As you can see in the code below we also make use of the XslCompiledTransform, this is done because the feeds contain two comments elements, even if they have different namespaces the ReadXml method of the dataset will throw an exception, since it will consider both of them as the same column. I got the idea to use to Transform from the next post, where the author got into the same troubles when loading two "comments" elements from the feed.
From lines 27 to 36 we initialize the class IndexPost with the values obtained from the feed, this values are then used by the IndexPostList control and allow some interaction with them like providing links to the post and forum URLs.
Aside loading the XML you will see that I added some extra features to be able to configure a few parameters regarding the posts we will display. This is done via a custom section I added to the web.config that is handled by the classes SectionHandler, FeedConfigurationCollection and FeedConfiguration. These classes will allow us configuring the feeds from which we will get the posts, the maximum number of posts to display per feed and the oldness of them. You can download the source code to see the full implementation. Do not forget to place the new assembly in the bin folder of CS and to set the configuration in the web.config.
Now that we can configure the feeds and to obtain the desired posts we need to modify the page home.aspx for each of the themes supported on our CS. First of all is to add our IndexPostList control with the information to show.
The main things to have in consideration is that we added the a new resource default_homepage_msdnrecentposts (file resources.xml of each language) to support several languages and a new css style CommonSearchResultArea.Msdn (file common.css of each theme), with this style we will modify the background image that appears left to the post.
The next step is to load the feeds and to bind the list of posts retrieved to the control, this is done in the OnInit event of the home page.
As you can see we also add the retrieved posts to the cache to avoid loading them from MSDN forums each time a user connects to the page, you can play with several factors to find which one fits better with your site.
Below you can see a screenshot of how the posts are displayed or even better just go to Baleares on .NET
That's all I hope you liked it.