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

Best of PDC09 Copenhagen – Scott Guthrie

by Jesper 3. December 2009 22:51

Attended a one day conference in Copenhagen today.
Great presentations of VS2010, .NET 4.0, MVC 2.0 and Silverlight 4 by Scott Guthrie

Wecome by Ole Kjeldsen Scott Guthrie

 Lunch Audience

Tags:

Conferences | .NET

.NET HttpListener Class - Weak documentation on Prefix formats

by Jesper 25. March 2008 17:48

Just thought I'd share this if someone else encounters the same problems I did trying to use this class.

The documentation for the .NET HttpListener class states that a Prefix host name + is similar to * without going into any further details.
There is actually a pretty big difference between the two.

There is also no mention of what happens when you specify an IP addresses as the host name (weak wildcard).

The full explanation is found in the MSDN documentation for the "HTTP Server API" under "UrlPrefix Strings".
See http://msdn2.microsoft.com/en-us/library/aa364698(VS.85).aspx

Tags:

.NET

Smart Paster Add-In for VS2008

by Jesper 10. February 2008 17:59

Just noticed that my favorite add-in for VS2005, Smart Paster by Alex Papadimoulis, is now also available for VS2008.

With this add-in you can paste text from the Windows clipboard into the Visual Studio source code editor formatted as a comment, quoted string, or string builder code just by right-clicking and selecting "Paste As..." from the pop-up menu:

This is just a fantastic time saver.

However the VS2008 version of the add-in only came as source code and had no instructions for installing it.
So for anyone else looking for this wonderful add-in, here's the compiled version:
SmartPaster2008bin.zip (27.13 kb)

To install it, un-zip above to:
Vista/2008: C:\Users\<user-name>\Documents\Visual Studio 2008\Addins
Earlier Windows: C:\Documents and Settings\All Users\Shared Documents\Visual Studio 2008\Addins

Then restart Visual Studio 2008 and update settings for the Add-In in the Tools menu / Add-In Manager.

Tags:

.NET | Software development | Software review

Microsoft's Software Licensing and Protection Services (SLPS) - Not for 64 bit

by Jesper 8. November 2007 02:52

I am attending Microsoft's TechEd Developer conference in Barcelona this week (and having a great time).
One of the more interesting things (to me) that Microsoft is showcasing this year is a new product for ISVs called "Software Licensing and Protection Services" or "SLPS".
There has been 2 "breakout sessions" on SLPS, there are signs, flags, and posters advertising SLPS everywhere, and there are more "ask the experts" stands about SLPS than any other single topic here.

SLPS is a very interesting anti-cracking method involving a "unique virtual machine permutation" for each ISV or software title combined with a typical license activation server or service. For details see http://www.microsoft.com/slps

It seemed like a great product for a small ISV like us, and so I spent some time digging into this subject here at TechEd.
Microsoft sells SLPS through various resellers including PreEmptive - who combines this with their DotFuscator product.
PreEmptive also has a stand at the TechEd, and they offer a "challenge" where they add SLPS (and obfuscation) to an existing .NET executable to demonstrate how all this works.

PreEmptive gave me a very nice walk-through using one of the .NET based .EXE modules from our upcoming Simple DNS Plus v. 5.0.
The protected / license wrapped version worked very nicely during the demo on PreEmptive's computer, and following the demo they e-mailed me a copy of this to try on my own computer.
Unfortunately it did not work as well when I downloaded the file to my laptop later that evening - basically it just crashed.

This morning I attended another session about SLPS by Aidan T. Hughes (Development Manager for SLPS at Microsoft), and later in the day got a chance to talk to him personally about this - and show him the application crashing on my laptop.
It turns out that SLPS only works with 32 bit processes!
Since my laptop runs 64 bit Vista, and the .NET application was originally compiled for "Any CPU", it runs as a 64 bit process.
This worked just fine before SLPS was added. But with SLPS it crashes because it cannot load the 32-bit-only SLPS DLLs into the 64 bit process.
Quoting Aidan: "We haven't gotten many requests for 64 bit support, so this is not something we have tested a lot..."
Unfortunately he didn't give me much hope that this would be fixed in the near future - "we will look into this for future versions...".
His only suggestion was to re-compile the application for 32 bit (x86 CPUs).

Unfortunately that is a showstopper for us.
Many of our users have been asking about 64 bit for some time now.
All new CPUs from Intel and AMD are 64 bit capable (both companies have stands at TechEd and I checked with them both) and Microsoft's own flagship product Window Vista comes with both 32 and 64 bit versions in the same box.
So I am surprised that Microsoft would launch this new product without 64 bit support.

That said, I would like to thank the staff at PreEmptive and Microsoft's SLPS group here at TechEd for their great help and personal attention to this.

Tags:

.NET | Conferences | Software development | Software review

Evaluating lightweight database systems

by Jesper 17. June 2007 02:40

I spent the past few days evaluating different embedded database system for possible use in the upcoming Simple DNS Plus v. 5.

Simple DNS Plus v. 5 will be .NET based, so my first requirement was that the database system had a .NET API or data provider.
Ideally it should run on both 32 and 64 bit Windows versions and under MONO on non-Windows systems (Linux, MacOS, Solaris, etc.).
And of course it should be fast and small as possible.

I looked at the following options:

1) Microsoft SQL Server Compact Edition (MS SQL CE).
(http://www.microsoft.com/sql/editions/compact/default.mspx)

At first this looked like the obvious choice since it is practically part of the Visual Studio toolbox (or will be in Visual Studio "Orcas").
However, at this time there is no 64 bit version, which would also prevent Simple DNS Plus from getting certified for Windows Vista (see http://channel9.msdn.com/ShowPost.aspx?PostID=312747).
And from what little information I can find, Microsoft has not committed to a 64 bit version in the "Orcas" timeframe either
(see http://blogs.msdn.com/stevelasker/archive/2007/01/16/sql-server-compact-edition-3-1-released.aspx#1753365)

Of course being win32 code it probably doesn’t run on non-Windows systems.
2) VistaDB
(http://www.vistadb.net)

This database system is a 100% .NET managed code DLL which can be linked directly into another .NET assembly. So this is truly an "embedded" database system.
The same code runs on both 32 and 64 bit – and even on non-Windows systems (under MONO).
The downside is that this is rather slow compared to the other database systems (according to my own simple speed tests), and the documentation is not great.

3) SQLite
(http://www.sqlite.org and http://sqlite.phxsoftware.com)

This was significantly faster than both MS SQL CE and VistaDB.

For .NET development, this is available as a hybrid DLL containing both the native code SQLite engine and the .NET provider.
Because of the included native code, there are separate DLLs for win32, x64, Itanium, and .NET compact which makes the total distribution size significantly larger than the other database engines.

A potential issue is that it has no type safety. Anything can be stored in any column.

I imagine the hybrid DLLs cannot be used on non-Windows systems, but the SQLite engine itself is available for many operating systems and as C source code, so there is probably some way around that…

4) Codebase
(http://www.codebase.com)

About 10 years ago I used this database engine to build a larger invoicing system with VB3 16 bit.
It was VERY fast back then and still is today.
It uses xBase data files which explains the speed (very simple and efficient file layout), but also why the data file becomes very large (data fields are padded to maximum length).
It has a .NET API but is itself native code. I am not sure if it works under MONO.

5) Firebird
(http://www.firebirdsql.org)

I didn’t actually get around to testing this, but wanted to mention it because it looks like another good option.
It has a .NET data provider but is itself native code. I am not sure if it works under MONO.

And the winner is… none!

Basically they were all just overkill for what I needed.
Had I chosen one, it would have been either VistaDB because it best fit my requirements or SQLite because it was very fast.

Instead of a database I ended up using a "homemade" highly optimized proprietary file structure.

A quick comparison of inserting 150.000 random records (representing 150.000 DNS zones):

VistaDB:
2 minutes

MS SQL CE:
1 minute

SQLite:
25 seconds

"Homemade":  
1/3 second (yes, one third of one second)

And the resulting "homemade" file was significantly smaller than any of the database files.

Read more about the "homemade" file structure here...

Tags:

Software development | .NET | Software review

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.