Code to compare two web.config file RRS feed

  • General discussion

  • For the two given web.config files (these are paths to the file) we must validate that both have the same amount of entries under the AppSettings (order is irrelevant) and they have the same values on each. If one or many entries (AppSettings nodes) are either missing or different in any of the two files, an exception is to be thrown with all (not only the first mismatch) found between the two files. Remember this should only apply to AppSettings child nodes.

    Example Content



        <add key="FeedCacheTime" value="300" /> DIFFERENT VALUES

        <add key="FeedPageUrl" value="/_layouts/feed.aspx?" /> SAME VALUES

        <add key="AdfsProviderName" value="ADFSv2" /> MISSING VALUE ON webConfigPath2




        <add key="FeedCacheTime" value="400" /> DIFFERENT VALUES

        <add key="FeedPageUrl" value="/_layouts/feed.aspx?" /> SAME VALUES

        <add key="CacheAuthenticatedIndividual" value="True" /> MISSING VALUE ON webConfigPath1


    • Edited by adityadugyala Wednesday, May 22, 2013 9:22 AM
    • Moved by Bob Beauchemin Thursday, May 23, 2013 2:11 AM Moved to a more appropriate forum
    Wednesday, May 22, 2013 6:00 AM

All replies

  • hi,

    how do you want to do the comparison? In SQL server or in .net code? The fisrt option is to use XQuery the second one is to use XmlDocument or use the XMlDiff Api.

    I hope it helps.


    There are 10 type of people. Those who understand binary and those who do not.

    My Blog | Hire Me

    Wednesday, May 22, 2013 11:54 AM
  • Uee this tool


    It will compare two web.config files and generate a web.config transform file from the differences.

    Disclaimer: I wrote it :)

    • Edited by Cameron_w55 Saturday, November 7, 2015 6:57 AM
    Saturday, November 7, 2015 6:57 AM