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,806
  • 12
  • 64
  • 111

3 Answers3

1

@html.raw(string) should do it

ebram khalil
  • 8,252
  • 7
  • 42
  • 60
Sam Axe
  • 33,313
  • 9
  • 55
  • 89
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,252
  • 7
  • 42
  • 60
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