1

I have a property in my Model which has string content similar to:

<p>Hello</p>`

Using @Html.Raw(myProperty) outputs to the browser

<p>Hello</p>

When I expect

Hello

I tried doing @Html.Raw(Html.Raw(myProperty)) but this reverted it back to the orginal string.

Is there any way to render this text as expected without resorting to using .Replace("&lt;", "<"), etc?

1 Answer 1

5

Try the following:

@Html.Raw(HttpUtility.HtmlDecode(myProperty))
Sign up to request clarification or add additional context in comments.

1 Comment

It happens when brain and hands are not properly connected! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.