Jesper's Blog

Publishing content to ASP.NET web-sites using Windows Live Writer

by Jesper 31. August 2010 02:36

Just released the all new Atom Publishing Protocol server library for ASP.NET.
Here's the background story:

Windows Live Writer is a wonderful application for writing blog posts.

image
It provides a much nicer editing experience than web-based HTML editors, and it is especially good at handling inserted images.
I have often wondered if there was some way to use WLW to edit news articles on our various web-sites (different home grown ASP.NET based systems) and/or use it for more general CMS purposes such as editing knowledge base articles and other web-pages.
Googling for ways to use WLW with ASP.NET did provide a few hints, but I couldn't find any ready-to-use components or complete code samples for this. So this weekend I set out to figure it out.

WLW supports a number of different "blog types":

image

However only one of these is based on RFC standards - the "Atom Publishing Protocol" - a.k.a. "AtomPub".
I am very much in favor of open standards, so I quickly decided that this was the way to go.

Chris Sells suggested creating an AtomPub server using WCF Data Services. However I felt that I needed something more flexible and "lightweight" - not tied to a specific database etc.

Our various web-sites have very different structures, use different background database layouts, are in different stages of development, etc. (but at least most of it is ASP.NET by now).
To make a "drop-in" AtomPub component that would work with all of this, it would have be to very flexible, especially in regards to data storage.
So I decided to make a library which handles all the AtomPub communications stuff (talking to WLW), but leaves the data storage and retrieval details up to each web-site using the library. Basically each web-site will have its own .NET classes which inherit from classes in this library and override methods to store/retrieve data.

Because the AtomPub protocol uses HTTP "PUT" and "DELETE" methods (to update and delete resources) and these methods by default are not handled by standard .aspx pages or .ashx handlers, it made more sense to implement the library as a custom handler (based on IHttpHandler) registered in the site's web.config file.
The PUT/DELETE methods also turned out to conflict with WebDAV - more details about this on the library home page (see link at top).

Putting everything together took a few days, but following the RFC documents, implementing the actual protocol was pretty straight forward. I used the standard .NET XML library and some simple string manipulation to parse and format the Atom XML messages, and the standard ASP.NET libraries to handle Atom related HTTP request and response headers.

The library works great with WLW and we are certainly going to continue implementing it on our various web-sites, making publishing news and other content easier and nicer going forward.

I am releasing this library to the public as freeware (see link at top), hoping that other ASP.NET developers might find it useful as well.

Tags:

Software development | .NET

Comments

1/14/2011 1:35:31 AM #

Source code?

kal | Reply

1/18/2011 2:34:01 AM #

hi I try to use that Library you mention
http://www.jhsoft.com/atompub-sl.aspx
and I got the handler build but seems that I am missing something because the handler nerver gets call and I get the typical "The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. "
So I don't know if you can help me solve this problem

eddieonofre | Reply

Add comment




biuquote
  • Comment
  • Preview
Loading



About Me

Jesper G. Høy - Professional software developer & amateur photographer. Lives in Frederikshavn, Denmark. Founder and director of JH Software

  

My Latest Photographs

At work

Visual Studio 2010

At play

My Camera

Frederikshavn Golf Klub

QR

Copyright

All content of this blog is copyright Jesper G. Høy unless otherwise noted.