Saturday, February 25, 2012

Corrupted Web Config in Sharepoint 2010

One of my dearest friend who is working for reputed corporate in Dubai called me this morning in verily panic toned. He narrated the story of how he ended up the whole SharePoint site's web config file got corrupted. He was helpless since 3 days of this incident.While he was working on the Server got power failure. After couple of hours,He checked the SharePoint Site it shows the IIS Error Page.
Initially I thought some of the .dll files reference must be added into the web config file.Because lot of third party applications were running on his server. I was shocked when he narrated his next explanation.He checked the web.config file on his default site.There were entries like random number as we seen in the movie "Matrix".:)- Quickly I could not think what could be possibilities those made this file corrupted.
Its really very strange error I encountered in my SharePoint developer career,Even I could not create some key words for search to this scenario. Some times before,I had as usual habit of clean up the temp files in windows,Log files in SP 2010 and .bak files in WebApplication. This time I wanted to check the .bak files those were created by system randomly for each web application in SharePoint on their virtual directories of the site. Again,I admit never tried to see what contents were inside of this .bak file.I disconnected my remote session and check my local computer's .bak file on my specific site. Whoops..! its just replica of your actual web.config of the Site. Logged back to his server.Scrutinize the timestamps of his all .bak file of his corrupted site. Simply opened this latest.bak file and copied its xml entries into new web.config file.Replaced with the corrupted web.config. Site got restored !..