Asp.net overrides runtime membership settings (asp.net mvc)

I had an application that connected to one separate database.

Now the application should connect to several databases. We want to use the same application / domain / hostname / virtual dir to give the user the opportunity to select "App / Database" on which they want to connect to the login screen.

Each database has application tables / data / procs / etc, as well as aspnet membership / role data.

When the user enters the username / password and selects (selects the list) the application, I want to check the user for the selected application database.

Currently, the database connection string for membership services is saved in the web.config file. Is there a way to override this during login? In addition, I need the “remember me” function to work smoothly. How it works, when the user returns to the application after 5 hours ... This process should be able to identify the user and the application and enter the system accordingly.

+5
source share
2 answers

The only possible way is to change the conn string through reflection:

// Set private property of Membership provider.FieldInfo connectionStringField 
= GetType().BaseType.GetField("_sqlConnectionString", BindingFlags.Instance | BindingFlags.NonPublic);
        connectionStringField.SetValue(this, connectionString);

Found here: http://forums.asp.net/p/997608/2209437.aspx

? , , . , , .

AFAIK , , cookie.

+5
0

All Articles