Asp.net override Membership settings at runtime (asp.net mvc)?

The only way possible is to change the conn string via reflection.

Up vote 3 down vote favorite share g+ share fb share tw.

I had an application that hooked onto 1 single database. The app now needs to hook into multiple databases. What we want to do is, using the same application/domain/hostname/virtual dir give the user the option on the login screen to select the "App/Database" they want to connect into.

Each database has the App tables/data/procs/etc as well as the aspnet membership/roles stuff. When the user enters the username/password and selects (select list) the application, I want to validate the user against the selected applications database. Presently the database connection string for membership services is saved in the web.config.

Is there any way I can override this at login time? Also, I need the "remember me" function to work smoothly as well. How does this work when the user comes back to the app in 5 hours... This process should be able to identify the user and application and log in appropriately.

Asp.net asp. Net-mvc asp. Net-membership membership-provider link|improve this question asked Apr 12 '10 at 23:25minalg9127 67% accept rate.

The only way possible is to change the conn string via 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 Why not just implement your own membershipprovider?

Very easy to do and then you have full control of whats happening. I'm sure you'll come up with another custom scenario the default provider doesn't work well with. AFAIK the remember me function should work exactly how your describing as long as the user doesn't delete their cookies.

Below is a link to an example using multiple connection strings for your membership providers. ASP. NET Forum - Multiple Providers.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions