Question

I'm parsing a Razor template that contains code such as

@model.Field

When Field includes a  , it gets escaped and turns into  .

How do I apply a real non-breaking space and prevent the escaping of &?

Was it helpful?

Solution

Use @Html.Raw(model.Field).

It will prevent HTML encoding of your data (which happens by default since Razor v3).

See MSDN and this Quick Reference by Phil Haack.

update

I now see you're using RazorEngine. In RazorEngine you can just use the built-in Raw method like this: @Raw(model.Field)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top