ASP.NET Membership on a Shared Host
What you need in a shared host if you want to use ASP.NET Membership:
1. ASP.NET 2.0 or better support.
2. MS SQL Database.
Recommendation:
Develop your web site as a file web on your local computer. That way you have an automatic backup and program response will be faster during development.
Procedure outline:
1. Use aspnet_regsql to install membership and roles on the hosted MS SQL Database.
2. Modify your web site’s web.config file to use the hosted MS SQL Database for Membership and Roles.
Details:
Using aspnet_regsql. You can use aspnet_regsql from the command-line or from the GUI. First, though, you have to find it. If your computer has a standard WinXP install, it will be in the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 directory. To run it from the command line, open a cmd prompt, navigate to the directory containing aspnet_regsql and enter the following (replacing the red text with the appropriate strings):
aspnet_regsql.exe -S domainNameOfHostedSQLServer -U DatabaseLoginId -P Password -d DatabaseName -A all
OR
If you prefer, you can use aspnet_regsql’s graphic interface, which will present a wizard. Just find it using Windows Explorer and double-click on it. The GUI looks like this:

Press “Next.”
Here’s the second screen:

Notice that you can also use this tool to remove the application services.
Press “Next” to reach the screen where you’ll input your specific database connection information:

There will be a couple more screens where the wizard will confirm your settings and report the status of the installation.
Modify web.config.
1. Use Windows Forms Authentication. In <system.web> node, the enter the following:
<authentication mode=”Forms” />
2. Enter the connection string for your database in the <configuration> node, enter the following:
<connectionStrings>
<remove name=”LocalSqlServer”/>
<add?
name =”LocalSqlServer”?
connectionString=”Server=domainNameOfHostedSQLServer;
Database=DatabaseName; uid=DatabaseLoginId; pwd=Password”
providerName=”System.Data.SqlClient”/>
</connectionStrings>
Note: you need not name the connection string “LocalSqlServer.” Choose whatever name you wish for it.
3. If you wish to use ASP.NET Roles, while paying special attention to the items in red, add the following to the <system.web> node:
<roleManager enabled=”true” defaultProvider=”SqlRoleManager”>
<providers>
<add
name=”SqlRoleManager”
type=”System.Web.Security.SqlRoleProvider”
connectionStringName=”LocalSqlServer”
applicationName=”myApplication” />
</providers>
</roleManager>
Note: use the connection string name defined in step 2 above. Choose whatever term you wish for the applicationName.
You should now be able to open the local copy of your web site in Visual Studio and use the Websit|ASP.NET Configuration menu item to manage membership and roles.
Posted: June 21st, 2008 under asp.net, membership, shared hosting, visual studio.
Comments: none