After playing around with some sharepoint features that wrote their settings to web.config I was left with a problem. After uninstalling the settings were still in the web.config and I had to manually remove the lines. It didn’t take long for the settings to reappear to the web.config. After some googling I found interesting blog post about this exact problem.

Because of my history with basic ASP.NET pages I presumed that the web.config would be just a static XML-file on the harddrive but I couldn’t been more wrong. Sharepoint stores programmatically added (Read more from MSDN) web.config modifications in the SQL database (by default) called Sharepoint_config_[GUID]. Randomly (server reboot, feature install/uninstall, IISRESET…) sharepoint recreates the whole web.config. It keeps the lines that are added or not stored in the config-database, but every line that exists in the database will be overwritten.

You can check the stored web.config modifications from the SQL server with a query: 

SELECT Id, ClassId, ParentId, Name, Status, Version, Properties
FROM Objects
WHERE    (Name LIKE ‘%WebConfig%’)

The interesting part is the column named ‘Properties’, because it contains the actual web.config modifications. The string is in XML-format so you are better of to just copy-paste it to some program, that knows how to format XML-properly (ex. Visual Studio)

From the same blog where I found description of this problem I also found two different solutions:

  1. Old school way (harder)
    • Direct manipulation of the SQL data. You can read the instructions from here.
  2. New school way (Easier)
    • Install “Web.Config Modifications” add-on to the Central Administration and delete the data from there. I’ve used this few times now and it’s really easy!
    • Now there’s also updated version from Harmjan Greving. You can download it from here.

But always remember that Microsoft does NOT support directly altering the data from the SQL server so don’t forget to take backups before doing this!

Tags: , ,