Derek
Derek

Reputation: 5855

Stop ">" symbol from being converted to ">" in web.config transform

When I run my Web.config transforms, it converts the > symbol to >. Is there a way to escape this conversion?

input:

<add key="MyPassword" value=">" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>

undesired output:

<add key="MyPassword" value="&gt;" />

desired output:

<add key="MyPassword" value=">" />

Upvotes: 0

Views: 737

Answers (2)

user2411670
user2411670

Reputation:

The Nature of XML prevents this.

In an effort to not leave you hanging here are some suggestions.

  1. google CDATA in Web.config,

  2. You may wish to create a method that 1. Reads the setting and 2. Decodes the value.

  3. With that being said, the nature of XML read and writes, this value should be returned unencoded. I see you are working with MVC. Just as a pointer perhaps this is working as intended and you simply need to @Html.Raw() your output in your view? Just a guess.

Good luck.

Upvotes: 0

Seano666
Seano666

Reputation: 2238

Unfortunately it looks like this is expected behavior. In this related question you can see the user submitted a bug to Microsoft, which they have closed as "By Design".

Web Config Transforms are HTML Encoding some of the config and breaking it

Upvotes: 1

Related Questions