How to attach ASP.NET Website administration tool to remote database

Here are some steps how to configure web site so that u can use web site administration tool for remote database.
 
You should have copy of your application locally  (it is not necessary, but it makes thinks easier)
 
Open local copy of website in Visual Studio
 
Go to web.config
 
Locate configuration/connectionStrings element
 
Type <remove name=”LocalSqlServer”/> as first child of <connectionStrings>
 
Type <add name=”LocalSqlServer” connectionString=”Data Source=myremoteip;Initial Catalog=mydatabase;Persist Security Info=True;User ID=me;Password=IWillNotTellYou” providerName=”System.Data.SqlClient” />
 
Replace @connectionString’s value with actual connection string to your remote SQL Server
 
Another way: It is also possible to avoid having 2 connection strings by forcint member provider to use your connection string named, say, MyConnectionString
 
Do not include <add name=”LocalSqlServer”…> (<remove> is still included)
 
Point your MyConnectionstring to remote MS SQL Server
 
In <system.web> locate or create
 
<roleManager>
 
Its content should be <providers><clear/><add name=”AspNetSqlRoleProvider” connectionStringName=”MyConnectionString” applicationName=”/” type=”System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”/>
 
<membership>
 
Its content should be something like
 
<remove name=”AspNetSqlMembershipProvider” />
 
<add connectionStringName=”MyConnectionString” passwordAttemptWindow=”10″ enablePasswordRetrieval=”false” enablePasswordReset=”true” requiresQuestionAndAnswer=”false” applicationName=”/” requiresUniqueEmail=”true”  passwordFormat=”Clear” description=”Stores and retrieves membership data from the Microsoft SQL Server database”                     minRequiredNonalphanumericCharacters=”0″ minRequiredPasswordLength=”4″ name=”AspNetSqlMembershipProvider” type=”System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” />
 
Note: This ‘another way’ is more complex than the first. You can (and possibly do) configure another properties of role and membership providers (those are my settings, not necessarily good for you). Basicly you need to remove old provider and then configure your own giving it name of MyConnectionString.
 
Launch Website | ASP.NET configuration
 
It’ll start  ASP.NET development server  and opens it in browser with Web Site Administration Tool.
 
Technically  you are configuring your local copy of the application, but the application is configured to use remote database. So, any changes made in web.config etc. will be made locally and any changes made in database will be made for your remote application.
 
I hope this helps developers that may run across this same issue!

Article ID: 84, Created On: 1/14/2012, Modified: 11/1/2013

Feedback (0)