Using the MSDN Clubsite with VS2010 and publishing it to Arvixe shared servers

I recently decided to try the MSDN Clubsite with VS2010. The Clubsite can be downloaded HERE.

I chose to work with the starter kit due to its great prebuilt calendar feature. After following the directions HERE I was able to get the clubsite to work in VS2010. If you do not have a copy of 2008 you can still use it, it gives an error “Error HRESULT E_FAIL has been returned from a call to a COM component.” But it does not appear to actually affect the functionality.

Testing it on my local machine went flawlessly; it was not until I tried to upload the site to Arvixe that I realized there was an issue.

Upon going to the test site I was confronted with “Failed to generate a user instance of SQL Server due to failure in retrieving the user’s local application data path. Please make sure the user has a local user profile on the computer. The connection will be

Online, there are many comments on how to fix this problem ranging from altering IIS permissions to manually adding the users to the default ASPNET database. Which in many cases works great, but it is not allowed with many shared hosting providers due to security issues

Here is my Step by Step to get the MSDN Clubsite to work on a shared host using Visual Studio 2010.

Step 1:
In Visual Studio, Go to FILE>New Web Site

This Step by Step will be in C# & .NET 4.0 so select Visual C# and then select the Club Web Site Starter Kit.

Give it name and click OK

When prompted about the site being configured to run on an older version. Click YES. (This is where you will see the HRESULT error)

Step 2:
After the site is loaded, Hit CTRL+F5 to run the site

Once the site opens, you can close your browser and return to Visual Studio.

Running the site once cause the Global.asax file to run, this checks for the Administrators role and creates it if it is missing.

Step 3:
Delete the Global.asax file

It will no longer be needed.

Step 4:
Go to Website>ASP.NET Configuration

Go to the Security tab, notice that existing roles is now at 1

Use the Security tab to create your users; these will be your site admins.

Close the Browser window when done.

Step 5:
In the Solution Explorer you should now see ASPNETDB.MDF under App_Data along with Club.mdf

Rename the 2 databases, this will help in the event another user on the shared server has already created ones with the same name. I changed ASPNETDB to cs_sec_1 and Club to CS_1. (You can pick whatever names you like)

Step 6:
Open the Web.config file and find the connection string, it should look like this.

<add name=”ClubSiteDB” connectionString=”Data Source=.\SQLExpress;Integrated Security=true; AttachDBFileName=|DataDirectory|Club.mdf;User Instance=True” providerName=”System.Data.SqlClient”/>

You will first need to change the club.mdf to the new name you chose for you database and then add a SECOND connection string to point to your security database. It will look like this (with the database names matching yours) Note: this connection string will not work on the Arvixe servers, please follow the instructions to see all the steps.

<add name=”ClubSiteDB” connectionString=”Data Source=.\SQLExpress;Integrated Security=true;
AttachDBFileName=|DataDirectory|cs_1.mdf;User Instance=True” providerName=”System.Data.SqlClient”/>
<add name=”cs_sec_1DB” connectionString=”Data Source=.\SQLExpress;Integrated Security=true;
AttachDBFileName=|DataDirectory|cs_sec_1.mdf;User Instance=True” providerName=”System.Data.SqlClient”/>

Step 7:
Now find the Role manager String, it should look like this.

<roleManager enabled=”true”/>

You will need to update this so it uses your new security database. In our example it will look like this.

<roleManager enabled=”true”>
<clear />
<add connectionStringName=”cs_sec_1DB” applicationName=”/”
name=”AspNetSqlRoleProvider” type=”System.Web.Security.SqlRoleProvider” />
<add applicationName=”/” name=”AspNetWindowsTokenRoleProvider”
type=”System.Web.Security.WindowsTokenRoleProvider” />

Note that the connectionStringName matches the name defined for our security database in Step 6.

Step 8:
Do the same for the Membership provider, it should look like this.

<membership defaultProvider=”AspNetSqlMembershipProvider”/>

You will need to update this so it uses your new security database. In our example it will look like this.

<membership defaultProvider=”MyMembershipProvider”>
<remove name=”AspNetSqlMembershipProvider”/>
<add connectionStringName=”cs_sec_1DB” minRequiredPasswordLength=”5″ minRequiredNonalphanumericCharacters=”0″
name=”MyMembershipProvider” applicationName=”/” type=”System.Web.Security.SqlMembershipProvider”/>

Step 9:
Press CTRL+F5 to build the site local to test if you got your connection strings correct.

If the site seems to work then it is time to move to Step 10 and setup your hosting provider databases.

Step 10:
Login to your control panel and create 2 MSSQL databases, preferably named the same as your MDFs created earlier.

Here I have created the Databases

Step 11:
Create backups of your MDFs using SQL Server Management Studio.
(this will be covered in my next tutorial)

Step 12:
Restore these backups into the new databases created using your hosting providers control panel.

Step 13:
Return to Visual Studio and make a copy of Web.config, I called mine so it’s easy to see which version is which
In this copy you will need to replace the Connection strings with the correct ones for Arvixe.
The Strings for them would be as follows (replacing the database names with the ones you used earlier)

<add name=”ClubsiteDB” connectionString=”Data Source=localhost;Initial Catalog=cs_1;Integrated Security=false;
User ID=yourdbusername;Password=yourpass” providerName=”System.Data.SqlClient”/>
<add name=”cs_sec_1DB” connectionString=”Data Source=localhost;Initial Catalog=cs_sec_1;Integrated Security=false;
User ID= yourdbusername;Password=yourpass” providerName=”System.Data.SqlClient”/>

Step 14:
Build the website to your hosting account.

Step 15:
On the remote site, rename Web.config to Web.config.offline and rename to Web.config
(you can choose whatever names you like while renaming I like using Online and Offline so I can tell the active ones appart.)

Step 16:
Enjoy your site

Tags: , , , , , | Posted under DotNet/Windows Hosting, MSSQL | RSS 2.0

One Comment on Using the MSDN Clubsite with VS2010 and publishing it to Arvixe shared servers

  1. on problem i have, when i postedwhite sitehave i made something wrong

Leave a Reply

Your email address will not be published. Required fields are marked *