0

I have a message which I want show it's body (which is a piece of html) using razor.

Somewhere in my cshtml file I have this:

<div>
    @message.Body
</div>

While the content of message.Body is: <p>Hello</p> the created html is:

<div>
    &lt;p&gt;Hello&lt;/p&gt;
</div>

But I want the result to be:

<div>
    <p>Hello</p>
</div>
mehrandvd
  • 8,250
  • 10
  • 54
  • 102

3 Answers3

1

@html.raw(string) should do it

ebram khalil
  • 8,071
  • 7
  • 39
  • 55
Sam Axe
  • 31,472
  • 7
  • 52
  • 80
1

What you need is to use @Html.Raw(HTML_String).

Kindly check Using Html.Raw in ASP.NET MVC Razor Views

ebram khalil
  • 8,071
  • 7
  • 39
  • 55
1

@Html.Raw(message.Body)

more info here: http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx/

Carlo Moretto
  • 365
  • 4
  • 16