What I found on the network about the problem is here :
A simpler, although somewhat eyebrow-raising solution simply modifies the connection string in providers early enough in the Life Cycle request:
private void SetProviderConnectionString(string connectionString) { var connectionStringField = Membership.Provider.GetType().GetField("_sqlConnectionString", BindingFlags.Instance | BindingFlags.NonPublic); if (connectionStringField != null) connectionStringField.SetValue(Membership.Provider, connectionString); }
Calling this method from Global.asax.cs inside Application_PreRequestHandlerExecute does the job. They have not tested too much, but even if something does not work, it just means that it needs to be done earlier. There are no guarantees that this will work with future versions of the structure, although, most likely, it will be.
Thus, the SetProviderConnectionString method can be called manually (after the completion of the Initialize method), instead of expecting the framework to call the rewritten Initialize method the first time it calls Memberhip.Provider.
d.popov
source share