Configuration config = WebConfigurationManager.OpenWebConfiguration("/WebPersonalExercises");
CompilationSection compSection = ((CompilationSection)(config.GetSection("system.web/compilation")));
compSection.Debug = true;
config.Save();
Please note that there might be times that this section is locked, so it is always helpful to check them first. Below is a revision C# code snippet to show that.
Configuration config = WebConfigurationManager.OpenWebConfiguration("/WebPersonalExercises");
CompilationSection compSection = ((CompilationSection)(config.GetSection("system.web/compilation")));
compSection.Debug = true;
if (!(compileSection.SectionInformation.IsLocked))
{
config.Save();
}