首页 > 代码库 > asp.net修改web.config文件

asp.net修改web.config文件

        private void UpdateConfigFile()        {            var cfg = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);            if (cfg.ConnectionStrings.ConnectionStrings["masterConnString"] == null)            {                var elCon = cfg.ConnectionStrings.ConnectionStrings["ElectricConnString"];                cfg.ConnectionStrings.ConnectionStrings.Add(new ConnectionStringSettings { Name = "masterConnString", ProviderName = "System.Data.SqlClient", ConnectionString = elCon.ConnectionString.Replace("Electric", "master") });                cfg.Save();            }        }

 

asp.net修改web.config文件