Update app.config system.net setting at runtime
I need to update a setting in the system.net SectionGroup of a .Net exe app.config file at runtime. I don't have write access to the original config file at runtime so I was hoping to save a copy of the file and replace the config in the exe with the modified version. I've tried the following but it's not working.  Any suggestions?

        Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        NetSectionGroup netSectionGroup = config.GetSectionGroup("system.net") as NetSectionGroup;
        netSectionGroup.Settings.HttpWebRequest.UseUnsafeHeaderParsing = true;                      
        config.SaveAs(@"C:\ProgramData\test.config", ConfigurationSaveMode.Full);

        AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", @"C:\ProgramData\test.config");
Update app.config system.net setting at runtime
===

I need to update a setting in the system.net SectionGroup of a .Net exe app.config file at runtime. I don't have write access to the original config file at runtime so I was hoping to save a copy of the file and replace the config in the exe with the modified version. I've tried the following but it's not working.  Any suggestions?

        Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        NetSectionGroup netSectionGroup = config.GetSectionGroup("system.net") as NetSectionGroup;
        netSectionGroup.Settings.HttpWebRequest.UseUnsafeHeaderParsing = true;                      
        config.SaveAs(@"C:\ProgramData\test.config", ConfigurationSaveMode.Full);

        AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", @"C:\ProgramData\test.config");