Restrict Auto Formatting of web.config file RRS feed

  • Question

  • User-978397479 posted

    I have some headers added under my web.config file which needs be in a single line. The headers are in XML format and are XML values, hence it is getting formatted.

    This line break is causing issue with my service call, as the end service requires the xml in a line only. There are some line break values which are getting appended during the calls.

    How can I resolve this issue ?

    1. Is there a way to not format the web.config file ?
    2. Is there a way to not format only a particular section under the web.config file ?
    3. Is there a way to replace the header section after auto-formatting is done ?
    Thursday, August 9, 2018 2:15 PM

All replies

  • User283571144 posted

    Hi sameer.s.panicker,

    According to your description, I couldn't understand your requiement clearly.

    Do you mean you want to disable the auto fomat in the VS?

    If this is your requirement, I suggest you could follow below steps:

    Step 1: Open ‘Tools’ -> ‘Options’
    Step 2: Select ‘Text Editor’ -> ‘XML’ -> ‘Formatting’
    Step 3: Set check box to not select

    Best Regards,


    Friday, August 10, 2018 9:28 AM
  • User753101303 posted


    Knowing the EXACT section you are trying to configure could help to better figure out what could be done. I have no idea if the XML could be encoded at this place or if maybe a CDATA section could be used ?

    Not directly related and I understand you want to fix this right away on your side, but it might worth to report that to the 3rd party if not done already.

    Edit: IMHO a "trick" like not having the web.config being formatted would be fragile at best. I would really use this as a very last resort.

    Saturday, August 11, 2018 6:25 PM
  • User-978397479 posted

    Thanks for the reply. I already tried using CDATA method, but it didnt work.

    I got this working in a different way for now. I updated my web.config file using powershell script after my package is created. After the update, I put my web.config in the same location and trigger the web deploy for publish. It grabs the latest web.config and things are working fine now.

    Friday, August 17, 2018 2:08 PM