I have the following section in Web.config
:
<httpProtocol>
<customHeaders>
<remove name="X-UA-Compatible" />
<remove name="X-Frame-Options" />
<remove name="X-XSS-Protection" />
<remove name="X-Content-Type-Options" />
<add name="X-UA-Compatible" value="IE=Edge" />
<add name="X-Frame-Options" value="DENY" />
<add name="X-XSS-Protection" value="1; mode=block"></add>
<add name="X-Content-Type-Options" value="nosniff" />
</customHeaders>
</httpProtocol>
and I would like to extract <customHeaders>
to a config file with the name web.customer.customHeaders.config
. In order to achieve this, I have created the web.customer.customHeaders.config
file in tha same location where my Web.config
is and I have written the folowing XML in it:
<customHeaders>
<remove name="X-UA-Compatible" />
<remove name="X-Frame-Options" />
<remove name="X-XSS-Protection" />
<remove name="X-Content-Type-Options" />
<add name="X-UA-Compatible" value="IE=Edge" />
<add name="X-Frame-Options" value="DENY" />
<add name="X-XSS-Protection" value="1; mode=block"></add>
<add name="X-Content-Type-Options" value="nosniff" />
</customHeaders>
I have also chsnged the <customHeaders>
section in my Web.config
file as such:
<httpProtocol>
<customHeaders configSource="web.customer.customHeaders.config" />
</httpProtocol>
but unfortunately, the configSource
attribute is not recognised. As a result, the extracted file, cannot be read and be inserted into my Web.config
file.
My question is: How can I extract a section from web.config in a seperate file.
In case you have any clue how this managable is, please leave a comment below.