</o> Hi, </o> I want to config Production Server Database and Staging Server Database Connection String in Same Application depends on Location path. </o> <LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in">Example. www.webapp.com (Root Directory) When I browse this site the production DataBase Server Connection String should be called through Web.Config of root directory. </o> <LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in">Example. www.webapp.com/LiveBeta (here ?LiveBeta? is a Sub Directory) </o> When I browse this site the Staging (Testing) Database Server Connection String should be called through Web.Config of sub directory. </o> Both the root and sub directory are same application. </o> How can I maintain both the application in one server with different Web.Config files depending on the directories? </o> I tried it out but received the error as connection string conflict. </o> How can toggle this issue in ASP.NET 2.0 with 2 Database in same server? </o> It's very urgent one. </o> Thank you Sundar
Give each folder a web.config with the needed conn string and use the "clear" and "remove" options for the previous strings. Use this link and search for ASP.NET 2.0 web.config examples for "add", "clear" and "remove": http://google.com/coop/cse?cx=009244845836111659857%3Albvxsjj8mho
You could define your own config section, and have nodes for each enviro tagged appropriately.Writean implementation ofIConfigurationSectionHandler to read the section and there you go. <section name="Sundars.appConfig" type="Sundars.AppConfigSectionHandler,Sundars"/> <Sundars.appConfig> <!-- [Your enviro specific stuff here] --> <config Config.ServerName="PROD" Config.ApplicationPath="?" SQL.ConnectString="Application Name=?;Data Source=?;Initial Catalog=?;Connect Timeout=30;Integrated Security=SSPI" ...ETC="?" /> <config Config.ServerName="TEST" Config.ApplicationPath="?" SQL.ConnectString="Application Name=?;Data Source=?;Initial Catalog=?;Connect Timeout=30;Integrated Security=SSPI" ...ETC="?" /> </Sundars.appConfig>
Actually, just checked, and IConfigurationSectionHandler has been "deprecated but retained since it is used internally" in 2.0. The new way MS wants you to do the same thing is to use the ConfigurationSection class. I havent implemented anything with this myself, but here's the msdn on it: http://msdn2.microsoft.com/en-us/library/system.configuration.configurationsection.aspx</BLOCKQUOTE>