ASP.NET ships with a SqlMembershipProvider and a ActiveDirectoryMembershipProvider that makes user authentication and authorization very easy to implement, but for some reason those are the only membership providers provided natively by ASP.NET 2.0. So, what do you do when you don't want or can't use SQL Server or Active Directory for memberships? You have to build a custom membership provider that suits your needs.

That’s exactly what I faced when I wanted an XML membership provider for a small web project. The only one I could find on the web was a very simple read-only xml provider from MSDN. I then changed it to be writable as well, so you can dynamically add new users among other things. I also encrypted the passwords so no one is able to make sense out of them when looking at the XML file.

It’s plug n’ play, it works and it makes user authentication ridiculously easy. Download the code at the bottom and dump the XmlMembershipProvider.cs class into the App_Code folder and the users.xml into the App_Data folder. Then write this in the web.config.

<membership defaultProvider="XmlMembershipProvider">

  <providers>

    <add name="XmlMembershipProvider" type="XmlMembershipProvider" description="XML membership provider" xmlFileName="~/App_Data/users.xml"/>

  </providers>
</membership>

Now you have a membership provider that enables you to make use of the collection of built in authentication controls. You can also interact directly with the provider without using the built in controls. Here's an example of how to create a new user:

MembershipCreateStatus status;

Membership.Provider.CreateUser("admin", "adminpw", "admin@domain.com", string.Empty, string.Empty, true, "admin", out status);

Even though you can access the provider programmatically, nothing beats the simplicity of the built in controls. To start using the XmlMembershipProvider, drag a CreateUserWizard to your webform and let the magic begin.

Download

XmlMembershipProvider.zip (3,45 KB)

Little Helper, the interactive help system for Headlight is now live and almost finished. It is build much like a Wiki so Headlight users can contribute and ask questions. I like to call it a good mix of a blog and an article base, because it works like a blog but without the chronology. The whole thing will be available for free download sometime in the near future.

The vision

We envisioned a community driven help system where people actively participated to create a better and more complete knowledge base. The application had to use best practices from Web 2.0 and .NET.

The technique

Little Helper is build entirely in C# and ASP.NET 2.0 after the principle of KISS. Everything is kept in a single Visual Studio website with no included class libraries, so it’s very easy to approach, extend and maintain. All the posts and comments are kept in XML files, so no database is needed. To summarize: it is plug n’ play.

Feature list

ASP.NET

  • URL rewriting
  • HTTP compression (HttpModule)
  • Whitespace removal (HttpModule)
  • ASP.NET 2.0 native themes support
  • Intelligent caching
  • Breadcrumb
  • Onsite search engine
  • Unlimited number of posts
  • Unlimited number of post sublevels (see the menu)
  • Multi language support

Web 2.0

Standards

Near future features

  • Social bookmarking support (Digg, del.icio.us etc.) - Done
  • Accesskey attribute for the menu - Done
  • Web service endpoints
  • Trackback and pingback support
  • Ping Technorati, PubSub etc.
  • Post organizer (drag n’ drop AJAX stuff)
  • Implement site configuration page
  • Google Sitemap
  • Multi user support - Done
  • Custom plug-in support

Stuff to improve

  • Better search algorithm - Done
  • Use ASP.NET 2.0 membership provider - Done
  • Use ASP.NET 2.0 profiles for user storage - Dismissed
  • Move all strings to resource files - Done
  • More microformats

It’s quite a big feature list, but as you can see, we still have things to do before we are completely done with the first version.