Search code examples
asp.net-mvc-3razorviewenginehtml-encode

HTML Encoding Strings - ASP.NET Web Forms VS Razor View Engine


I'm not quite sure how this works yet... trying to find documentation.

In my existing app I've got two different ways of rendering strings in my View

<%: model.something %>
<!-- or -->
<%= model.something %>

The first one is html encoded, and the second one is not.

Is there something similarly short in Razor? All I can find is this, which is the encoded version.

@model.something

Solution

  • I guess the best approach would be to use the Raw extension-method: @Html.Raw(Model.Something)