I wrote a sharepoint application that needs to change web.config
I have a function that should do all of these configurations. The code for this function is as follows:
SPSite site = properties.Feature.Parent as SPSite; List<SPWebConfigModification> modifications = new List<SPWebConfigModification>(); modifications.AddRange(CustomErrorsModeConfig.Modifications); webConfigModificationHelper.AddWebConfigModifications(site.WebApplication, modifications);
The CustomErrorsModeConfig.Modifications property contains this code:
public static SPWebConfigModification[] Modifications = { new SPWebConfigModification() { Owner = WebConfigModificationOwner, Name = "mode", Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute, Path = "system.web/customErrors", Sequence = 0, Value = "Off" } };
Then, finally, the webConfigModificationHelper.AddWebConfigModifications method:
foreach (SPWebConfigModification modification in modifications) { webApp.WebConfigModifications.Add(modification); } webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications(); webApp.Update();
The problem is that I keep getting this error:
Name cannot begin with the ''' character, hexadecimal value 0x27. Line 1, position 1453
Could this be a problem with web.config before I try to apply my changes?
Is the SPWebConfigModification property defined incorrectly?
Is there some kind of glitch in my code that leads to this error?
Could there be some property that I am missing (e.g. web.AllowUnsafeUpdates)?
Some sharepoint site configuration?
I tried to solve this problem for some time without any luck :( Any ideas?