문제

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 &?

도움이 되었습니까?

해결책

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)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top