Prevent encoding of attribute in a html element.



i need to prevent encoding of some attributes and I wonder if there is some easy solution.

The code that is used: <img src="<%= AdTractionUrl %>" width="1" height="1" />

The only thing I can come up with is to write a responsefilter that reverse encoding of the attribute.

Any better solutions?

Feb 03, 2012 11:15

Trying to paste the code again: <img src="<%= AdTractionUrl %>" width="1" height="1" />

Feb 03, 2012 11:16

<%= AdTractionUrl %> won't be encoded, at least not by the binding expression. Are you sure you're not encoding this when setting the property?

Feb 06, 2012 10:37

That's right, the problem was not an encoding issue. It was my browser that encoded the url in view-source.

Feb 07, 2012 7:50

However, attribute values are supposed to be encoded (for instance bare &'s are not allowed).

Is there really some reason why you'd want it not to be encoded (one would think there'd be less risk of breakage with it properly encoded than not)? 

Feb 07, 2012 11:38

Hijacking this old thread :)

We have a case where we actually have a reason why it shouldn't be encoded: when using Akamai Edge Side Includes, such as this:

<esi:when test="$exists($(HTTP_COOKIE{'mycookie'}))">


It seems that HtmlRewritePipe.WriteElement does encode attribute values, even for elements that it doesn't touch and non-valid HTML elements. Any bright ideas on how to work around this?

Mar 05, 2014 20:49
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.