Our web application needs to set the provider's connectionstring at run-time. I have reviewed the following old post:
http://forums.asp.net/p/997608/4966000.aspx/1
The solution that I have considered from such an old post is the one given by RGabo:
private void SetProviderConnectionString(string connectionString)
{
// Set private property of Membership, Role and Profile providers. Do not try this at home!!
var connectionStringField = Membership.Provider.GetType().GetField("_sqlConnectionString", BindingFlags.Instance | BindingFlags.NonPublic);
if (connectionStringField != null)
connectionStringField.SetValue(Membership.Provider, connectionString);
var roleField = Roles.Provider.GetType().GetField("_sqlConnectionString", BindingFlags.Instance | BindingFlags.NonPublic);
if (roleField != nu ...
Go to the complete details ...