[英]web.config in asp.net
我想在web.config中提供來自數據庫的username,password和APIKey的值。這意味着必須在web.config中設置管理員設置的username,password和APIkey。 我該如何更改。任何想法。
謝謝。
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();
}
}
但是,每次您更新web.config文件時,它將重新啟動您的應用程序域,因此,不建議頻繁更新web.config。
請參考:以編程方式編輯Web.config
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.