Deliver superior customer experiences with an AI-driven platform for creating and deploying cognitive chatbots
Deliver Awesome UI with the most complete toolboxes for .NET, Web and Mobile development
Automate UI, load and performance testing for web, desktop and mobile
A complete cloud platform for an app or your entire digital business
Detect and predict anomalies by automating machine learning to achieve higher asset uptime and maximized yield
Automate decision processes with a no-code business rules engine
Optimize data integration with high-performance connectivity
Connect to any cloud or on-premises data source using a standard interface
Build engaging multi-channel web and digital experiences with intuitive web content management
Personalize and optimize the customer experience across digital touchpoints
Build, protect and deploy apps across any platform and mobile device
Rapidly develop, manage and deploy business apps, delivered as SaaS in the cloud
The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
As a side project, I’m experimenting with moving Sitefinity Watch to the Sitefinity 4.0 BETA. As of this writing, there are no migration tools that can be used to migrate blog posts from Sitefinity 3.x to Sitefinity 4.0. We will eventually deliver these migration tools, but this project gave me an excuse to experiment with using Sitefinity 4.0’s Fluent API to import content.
Ivan Osmak highlighted the Fluent API in our Sitefinity 4.0 BETA webinar. The Fluent API enables .NET developers to query and manipulate Sitefinity data in very powerful ways.
Disclaimer: What I’m going to share in this blog post needs a lot of work. I’m not yet done with it. Later I’ll explain the issues I still need to solve. However, rather than sit on this code for weeks, I wanted to share what I have working. Later I can iterate. Alternately, if someone wants to steal this code and extend it…feel free. I will gladly link to your blog posts and credit your work.
As a first step, I simply wanted to point to an RSS feed and import these RSS items into a Sitefinity 4.0 blog. This obviously isn’t a full fledged import utility, but it’s a reasonable first step.
Before importing blog posts, I needed to first create a new blog in Sitefinity 4.0.
This was the easy part.
There are some assembly references that needed added before custom code can be added to a Sitefinity project. This instructions (and links) below describe how to prepare a Sitefinity project for custom development.
1. Open the Sitefinity project in Visual Studio
2. Add the missing assembly references. <- Important!!
3. Add an assembly reference to System.Linq.Xml
The project is now prepared for custom development.
To import blog posts, I needed to run a small bit of code within the context of my Sitefinity web site. There are various strategies for doing this (for example, I could create a custom UserControl or use Sitefinity Services), but I chose to create a new ~/blogimport.aspx page in my Sitefinity web site.
The instructions below describe how to create this ASPX page:
1. Right-click the SitefinityWebApp project in the Solution Explorer and click New Item
2. Select Web Form and type blogimport.aspx for the Name
3. Open the code-behind file for the blogimport.aspx page
The code for fetching the RSS items and importing these items into Sitefinity (using the Fluent API) is posted below. Comments have been added throughout the code to explain what is happening.
public partial class blogimport : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
// Get the RSS feed from Sitefinity Watch
var blogRSS = XDocument.Load("http://feeds.feedburner.com/SitefinityWatch");
// Get the RSS items from the feed
var rssItems = from d in blogRSS.Descendants("item")
// If the executing code isn't wrapped in a using, then changes aren't committed
using (var fluent = App.WorkWith())
// Get the blog object associated with my Sitefinity Watch blog
var blog = (from b in fluent.Blogs().Get()
where b.Title == "Sitefinity Watch"
// Print the ID, to confirm I got it
Response.Write(blog.Id.ToString() + "<br />");
// Loop through each RSS item
foreach (var item in rssItems.ToList())
// Print the Title for each blog post
Response.Write(item.Element("title").Value + "<br />");
// Add the blog post from the RSS feed to my Sitefinity 4.0 blog
b.Title = item.Element("title").Value;
b.Content = item.Element("description").Value;
b.PublicationDate = DateTime.Now;
b.ExpirationDate = DateTime.Now.AddDays(10);
The blog posts found in the RSS feed can be imported by accessing the import page in a web browser. Because the Sitefinity Fluent API is bound by Sitefinity permissions you must be authenticated before accessing the page.
1. Login to Sitefinity
2. Access the ~/blogimport.aspx page in a web browser.
3. View the blog in Sitefinity to confirm the blog posts were imported.
This is a nice first step. However, this is not a fully developed import process. The technique described above has several challenges associated with it.
These are challenges that I still need to work through. In the meantime, this might be useful to anyone who is experimenting with Sitefinity’s Fluent API.
Thanks to Ivan Dimitrov and Robert Shoemate for helping me with this code.
View all posts from The Progress Guys on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.