Behind the Curtain - ASP.NET 2.0 Membership
In part 1
of our series, I showed what you can expect from the rest of this series. If you remember, we had a user named Jane that we migrated from an ASP.NET 2.0 Membership database into Auth0 and also into Kentico. While you now know the end result, let’s understand each of the moving parts, starting with the ASP.NET 2.0 Membership database.
ASP.NET 2.0 Membership
Do you remember this guy from the early 2000s? If not, don’t worry too much about it as it is not something that many people use any longer, thus the reason I was looking for a solution on migrating away from this database in the first place. If you are really feeling nostalgic, and you want to learn much more about this than what I am going to get into, the old 4 Guys from Rolla
have a great tutorial explaining everything. Man, I learned so much from them back in the day.
Since this is an older way of doing things, getting a database setup in the first place was quite a challenge. With Visual Studio 2010, you could add this right from the Solution Explorer, however, Microsoft has since removed this from Visual Studio. Now, the only way we can get this database to be created is by using Command Prompt with the following command:
You will be prompted with a wizard to setup the initial database. I set up my database on Azure as you have to open quite a few firewall ports for scripts to work correctly on Auth0 (which we will touch on in part 3 of this series). In order to do this, however, you will need to setup the database locally using this wizard and then it can be restored on Azure as Azure does not support the scripts in this application that are used to create this database.
Once the database has been created, it will look like the following...
Here is where it gets a little tricky. Since we no longer have the admin tool built right into Visual Studio, we need to determine a different way to display this tool so we can fill our database with users and roles. I performed the following steps to get my administration tool to be displayed…
Setup a new Web Site Application that uses ASP.Net Membership. This is necessary for the ASP.Net Web Site Administration Tool to run correctly.
- Create an ASP.NET Empty Web Site (it is important that this is a website and not a web application)
- Modify the web.config file to contain the following:
- Connection to the ASP.Net 2.0 Membership Database that will be used. I pointed my connection to the Azure instance of my database.
- Add configurations for Membership, Profile, and RoleManger providers
make sure C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files has full access by EVERYONE
NOTE: Keep in mind that full access by everyone is never a great practice, but when working on a development machine, this is okay.
In a Command Prompt, change the directory to C:\Program Files\IIS Express
Type the following in Command Prompt: iisexpress.exe /path:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ASP.NETWebAdminFiles" /vpath:"/ASP.NETWebAdminFiles" /port:51111 /clr:4.0 /ntlm
NOTE: Port 51111 was used for my setup, but this port can be any that you like.
Browse to the following location: http://localhost:51111/asp.netwebadminfiles/default.aspx?applicationPhysicalPath=[path of the application created in Step 1]&applicationUrl=/
There we have it, the creation of the ASP.NET 2.0 Membership Database. From here, you can create new roles and users that you want to try and migrate.
NOTE: While an ASP.NET 2.0 Membership database might be exactly what you are looking for, this entire process is not dependant on this part whatsoever. Any database could be used and the process of migrating users would work just about the same. In other words, what you see here has no real bearing on the final result, but it was a problem that I took entirely too much time on trying to solve, so I am passing along my knowledge to you.
In part 3 of this series, I will walk you through the complete setup of Auth0, including the scripts used to migrate our newly created user and their roles into an Auth0 database.