Editing web.config while deploying
-
Hi, While deploying a web application i have to set the new connection string in the web.config file. The code i used is given below ------ try { Configuration config = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath); AppSettingsSection section = (AppSettingsSection)config.GetSection ("appSettings"); section.Settings["conString"].Value = str; // connection string WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath); config.Save(ConfigurationSaveMode.Modified); } catch (Exception ex) { } -------------------------- When i'm executing the code in the visual studio framework , it works fine. When the web.config is changed, save confirmation message appears there. But when deploying, the web.config file is not get updated permanently. As there is no error in the code no exception arises there. Any help w'l be appreciated. Thanks in advance. Regards Nicejith