65.9K
CodeProject is changing. Read more.
Home

How to edit Configuration file Web.Config

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Oct 11, 2013

CPOL
viewsIcon

6110

How to edit Configuration file Web.Configin web.config we use section to add keys as you see      <add key="email"

How to edit Configuration file Web.Config

in web.config we use <appSettings> section to add keys as you see

  <appSettings>

    <add key="email" value="" />

   <add key="color" value="green" />

  </appSettings>

in code behind write this code to enable us reach to Keys and get value

 Configuration conf = WebConfigurationManager.OpenWebConfiguration("~");

        AppSettingsSection app = (AppSettingsSection)conf.GetSection("appSettings");

        app.Settings["email"].Value = TextBox1.Text;

        app.Settings.Add("color", "green");

        conf.Save();

hope this useful