私は wbe アプリ mvc c#4.0 を持っています。実行時にコードから DefaultRoleProvider 接続文字列を初期化したい (web.config からは望まない)。クラス MyRoleProvider を作成しました: DefaultRoleProvider
public class MyRoleProvider : DefaultRoleProvider
{
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
base.Initialize(name, config);
// Update the private connection string field in the base class.
bool IsLocal = bool.Parse(ConfigurationManager.AppSettings["IsLocal"] as string);
string connectionString = "local connectionString ... ";
if (IsLocal == false)
connectionString = "prod connectionString ...";
//ToDo- how to set connection string next property of provider.
??
}
}