When XDT (XML Document Transform) is not working on the URI section in the web.config file, there are a few potential reasons and solutions to investigate:

  1. Incorrect XDT Syntax: Ensure that your XDT syntax is correct. The syntax for transforming the URI section in the web.config should follow the XDT standards. For example, the xdt:Transform attribute should be set to "SetAttributes" or "Remove" based on what you want to achieve.

    Here's an example of how to add or modify the uri attribute using XDT:

    <!-- Original web.config --> <system.webServer> <security> <requestFiltering> <fileExtensions> <add fileExtension=".exe" allowed="true" /> <!-- We want to add or modify the uri attribute below --> <add fileExtension=".pdf" allowed="true" uri="pdfhandler.aspx" /> </fileExtensions> </requestFiltering> </security> </system.webServer>
    <!-- Transform file (web.release.config or web.debug.config) --> <system.webServer> <security> <requestFiltering> <fileExtensions> <add fileExtension=".pdf" allowed="true" uri="newpdfhandler.aspx" xdt:Transform="SetAttributes(uri)" /> </fileExtensions> </requestFiltering> </security> </system.webServer>
  2. Incorrect Configurations: Ensure that you are using the right configuration files for transformation. The transform file should have the same name as the target file, with the additional suffix indicating the environment (e.g., web.release.config or web.debug.config).

  3. Config Transforms Not Applied: Verify that your build process includes the transformation of web.config files based on the build configuration (e.g., Release or Debug). If the transform files are not being applied during the build, the changes won't take effect.

  4. Configuration Manager Settings: Check the Configuration Manager settings in your Visual Studio project. Make sure that the "Build" checkbox is checked for the appropriate build configuration (e.g., Release or Debug) and that the "Configuration" dropdown corresponds to the intended transformation.

  5. Build Events: Review any custom build events or scripts that may interfere with the configuration transformation process. Ensure that they are not overriding or interfering with the transformations.

  6. Verify the Section: Double-check the URI section's XPath in your web.config file to ensure that it is targeting the correct element. Use the XPath syntax to accurately locate the element that needs to be transformed.

If you have verified the above points and are still experiencing issues, please provide more specific details about your web.config, transform file, and the actual transformation you are trying to achieve, so that I can assist you more effectively.

Have questions or queries?
Get in Touch