You can modify web.config at run time. For exmaple to add a property in app settings section of web.config, you can use the following c# code
Configuration myConfiguration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
myConfiguration.AppSettings.Settings.Add("CommentsLimit", "10");
myConfiguration.Save();
To update the existing property:
Configuration myConfiguration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
myConfiguration.AppSettings.Settings["CommentsLimit"].Value = "20";
myConfiguration.Save();
No comments:
Post a Comment