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

asp.net-mvc-3html-encoderazorviewengine

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

Best Answer

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