First post, I'm a complete newbie .Net / C # thrown into the deep end!
I inherited the C # wed application because someone went to work and I was the only one with bandwidth! But not knowledge of .Net, C #!
The application is used by people on different sites around the world. They are registered using corporate login data and, as such, are registered on different servers depending on where they are located (Europe, America or India).
The guy who wrote the application was not able to decide how to switch ConnectionString to web.config depending on the location, so it duplicates the entire application for each domain! The only option is the single IP address in web.config for each duplicated version of the application! Then a simple web page appeared, on which the user βhad hisβ version of the application, depending on where they said they were in the world!
The first thing I want to do is upgrade to one version for support, so I need to be able to switch the connection string or how to log in?
I spent several days figuring out how I access ConnectionString (defined in web.config) from my Login class, only to find the values ββset in web.config, it seems to be read-only, t change them.
So, I guess the first question is: am I barking the wrong tree? Can I just set all the information that AspNetActiveDirectoryMembershipProvider requires (see code later) and call it from my login class? Or is the ConnectionString path an Ipso facto way to establish connections in .Net / C #? So I need to figure out how to change / specify / add value at runtime.
Three possibilities that I can think of: - (The first is what I founded hult with)
Change ConnectionString for ADService in my web.config from my Login class?
Change what AspNetActiveDirectoryMembershipProvider uses, so from my Login class magically get it to use EMEA_ADService or PACIFIC_ADService, as defined in web.config?
- Is it possible to define a new connectionString and call AspNetActiveDirectoryMembershipProvider all of my Login class without using web.config for this connection at all?
Here is a bit of my / his web.config file and my login class
Worms from Web.config
<connectionStrings> <add name="ADService" connectionString="LDAP://12.345.67.8" /> *---- Original ConnectionString (IP address changed)----* <add name="EMEA_ADService" connectionString="LDAP://12.345.67.8" /> *---- Added by me playing around unsuccessfully! ----* <add name="PACIFIC_ADService" connectionString="LDAP://12.345.67.9" /> *---- Added by me playing around unsuccessfully! ----* ~ </connectionStrings> <authentication mode="Forms"> <forms loginUrl="~/Login.aspx" timeout="2880" /> *---- The background class for this popup (Login.aspx.cs) is where I'm currently trying to affect ConnectionString----* </authentication> *---- Pretty sure this is the bit that actually does the login verification----* <membership defaultProvider="AspNetActiveDirectoryMembershipProvider"> <providers> <clear /> <add name="AspNetActiveDirectoryMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=12345678" connectionStringName="ADService" applicationName="/." description="ADService" /> </providers> </membership>
This is, as I understand it in my class, before figuring out that I cannot change the ConnectionString!
Worms from Login.aspx.cs
public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { ConnectionStringSettingsCollection connections = ConfigurationManager.ConnectionStrings;
Any hint would be very welcome!
PS I requested the .Net / C # course at work !;)