i just came up with the reading, Writing and adding values dynamically in web.Config in asp.net. Have many ideas in mind, but i just wana know what is the best way of adding values in web config dynamically.
for example in my case i have to add
<identity userName="someDomain\User" password="password" impersonate="true" />
in
tag in web config from code behind.
waiting for Good responses
I got you and the code you want is :
public void saveIdentity(string username, string password, bool impersonate)
{
Configuration objConfig = WebConfigurationManager.OpenWebConfiguration("~");
IdentitySection identitySection = (IdentitySection)objConfig.GetSection("system.web/identity");
if (identitySection != null)
{
identitySection.UserName = username;
identitySection.Password = password;
identitySection.Impersonate = impersonate;
}
objConfig.Save();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With