Html Encoded Output In View Templates


The existing <%= %> syntax would keep output the raw strings, so it can be used to output properties that has markup inside, like CMS data, the ViewContents in layouts, CaptureFor data, etc.

If you want http encoded output, use <%# %> or ${} instead.


Given the following view template:

&lt;%string markup = "<span&gt;";%>&lt;%=markup%&gt;&lt;%#markup%&gt;${markup}

The rendered output would be:


Have fun.

     Tweet Follow @kenegozi