Monthly Archives: January 2009

default ASP.NET Membership provider on different database

Every ASP.NET developer should already know about the Membership Provider that ships with ASP.NET 2.0. Configuring it is as easy as opening Visual Studio > select the Web project file > navigate to the Project menu item > and select “ASP.NET Configuration”. Follow the wizard and you are up and running now.

But the problem with this approach is that it will build it’s OWN database in the App_Data folder and create the required tables there. Wouldn’t most of us have their own databases to work with? ok then, if you want the defualt ASP.NET Membership Provide (AspNetSqlMembershipProvider) to work on YOUR database do the following:

  1. Navigate to the folder: “C:\Windows\Microsoft.NET\Framework\v2.0.50727” and run the “aspnet_regsql.exe” file, follow the wizard (it’s pretty easy, see the images below)


    This step will create the Membership and Profile Provider tables necessary; if you are lucky you will see many dbo.aspnet_something tables.
  2. Now we need to tell the website which Provider it should use for this functionality, and to which database it should connect to; the default configuration information that drives the default behavior of the default Provider resides in the Machine.config (C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG), which explains why you can’t find the configuration information on YOUR web.config even after you finish using the ASP.NET Configuration mini-website.
    The best thing to do is to copy that configuration information from the machine.config to your website web.config in order to override its behavior to our desired one, for more information about configuration files and configuration hierarchy read this.

    <membership defaultProvider=AspNetSqlMembershipProvider >



            <add name=AspNetSqlMembershipProvider type=System.Web.Security.SqlMembershipProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a connectionStringName=”BunianConnectionString” enablePasswordRetrieval=false enablePasswordReset=true requiresQuestionAndAnswer=true applicationName=/ requiresUniqueEmail=false passwordFormat=Hashed maxInvalidPasswordAttempts=5 minRequiredPasswordLength=7 minRequiredNonalphanumericCharacters=1 passwordAttemptWindow=10 passwordStrengthRegularExpression=“”/>



    Note that highlighted changes:

    1. clear any previous configuration of the AspNetSqlMebershipProvider (machine.config) which if not moved will give you an error of already being configured
    2. changing the connection string to mach a connectionstring name that you use to connect to your database in general

This way you will have the default Membership Provider running on your database for your website; if you use the mini-site for the ASP.NET Configuration now and create new users, you will find them created in your database.

Note that some resources say that you can change the database from the ASP.NET Configuration but I couldn’t find it there.

Disclaimer: use the above on your own responsibility 🙂

Get On With It!

clockWhen we started gathering requirements from the charity organizations for Bunian, it appeared that there are other kinds of people who benefit from the charity organization; there are “needy families” whose father is still alive but can’t sustain their families, and “students” who can’t afford their study. 

So Bunian needs to support all these Beneficiaries in smart way; we solved the problem by creating the IBeneficiary interface. But the problem is that in order to get out with the best solution ever (damn perfectionism!), we kept coming up with different solutions, and overriding them with other solutions every once in a while, and this kept going like forever!

Though we agreed from the beginning that we shall keep it as simple as possible and then add up to it as we get out with the first phase, yet it kept sliding “ok only we have to do this, oh and that too”. Until one day I thought I came up with the silver bullet everyone talks about 4 , and sent an email to the group about the changes I wanted to make, when a colleague caught me online and showed her objection about the new solutions, and proposed another. Only then I woke up!! “OMG…WE ARE STILL HERE!!”
Instantly, I remembered my oldest brothers comment  (Mohammad, very wise brother) about Bunian “It’s great that you want to build the greatest architecture ever, but remember that Orphans are waiting!!

So LET’S JUST GET ON WITH IT!! ship it!! do it!! let version one come out, let “customers” benefit from it, then you take your time doing your silver bullet. So this is one of the challenges facing the Project Managers, something we developers rarely think about :); today…I learned my lesson!