Finished installing WinVi Beta 1 on my IBM X31. It always pays off to have spare partitions when you do OS Beta testing on a regular basis.
IE7 already annoys me - dasBlog (or ASP.NET to be more precise) doesn't know about this browser and thus only presents me we an HTML input box instead of FTB. Well, Firefox will find its way onto this box rather sooner than later anyways.
Vista defaults to a US keyboard on initial startup (surprising, but no showstopper for me). Well, and it didn't find my onboard wireless. This I definitely need to fix, because I want to use it for work.
Did you know that the Membership API isn't limited to being used inside ASP.NET 2.0 applications? That you can also use it in say a Console application? This is actually very useful, because that spells automated administration for me.
In order to demo this, I set out and created a very simple Web application that lists users registered with the Membership system:

This simply calls Membership.GetAllUsers() and we are set. More interesting is web.config (partial view):
<connectionStrings>
<add name="NWConn"
connectionString="Data Source=cbc05vpc\cbc05;Initial Catalog=Northwind;User=sa;Password=P@ssw0rd"/>
</connectionStrings>
<system.web>
<membership defaultProvider="myMembership">
<providers>
<clear/>
<add name="myMembership"
applicationName="DemoApp"
connectionStringName="NWConn"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, ..." />
</providers>
</membership>
This is using the stock SqlMembershipProvider, and stores data inside the Northwind database. Pretty vanilla, except for one important attribute: applicationName. Because one Membership database can hold accounts for multiple applications, we need to define the name here unless we want to end up with guessing that name for the console application.
Now let's switch to the Console application. It obviously needs to reference System.Web.dll:

Secondly, it needs an App.Config file (this time, in full glory):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add
name="NWConn" connectionString="Data Source=cbc05vpc\cbc05;Initial Catalog=Northwind;User=sa;Password=P@ssw0rd"/>
</connectionStrings>
<system.web>
<membership defaultProvider="myMembership">
<providers>
<clear/>
<add name="myMembership"
applicationName="DemoApp"
connectionStringName="NWConn"
type="System.Web.Security.SqlMembershipProvider, System.Web, ..." />
</providers>
</membership>
</system.web>
</configuration>
As you can see, I simply copied its contents verbatim from the previously shown web.config. All we now need is to access the Membership API inside our application:
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Security;
namespace TheConsoleApp
{
class Program
{
static void Main(string[] args)
{
MembershipUserCollection muc = Membership.GetAllUsers();
foreach (MembershipUser mu in muc)
Console.WriteLine(mu.UserName + " " + mu.Email);
}
}
}
Surprise, surprise - it works as expected:

Done.
MembershipEverywhere.zip (19.28 KB)