开发者

web.config in asp.net

开发者 https://www.devze.com 2023-01-09 14:13 出处:网络
i want to give the values of username,password and APIKey i开发者_C百科nweb.config which are coming from database.means whatever the admin set username,password,APIkey that has to be set in web.config

i want to give the values of username,password and APIKey i开发者_C百科n web.config which are coming from database.means whatever the admin set username,password,APIkey that has to be set in web.config. how can i change this.Any idea.

thank you.


 private void UpdateConfig(string strKey, string strValue)
{
   Configuration objConfig =
      WebConfigurationManager.OpenWebConfiguration("~");
   AppSettingsSection objAppsettings =
      (AppSettingsSection)objConfig.GetSection("appSettings");
   if (objAppsettings != null)
   {
      objAppsettings.Settings[strKey].Value = strValue;
      objConfig.Save();
   }
}

But it will restart your application domain every time you update the web.config file, so, updating the web.config frequently is not advisable.

Pls refer : Editing Web.config programatically

0

精彩评论

暂无评论...
验证码 换一张
取 消