passing a string with line break on to a cshtml pa

2019-07-23 13:56发布

问题:

I have a mypage.cshtml as below

<p><span>@r.get("My_Message")</span></p>

Below is my entry in my resx file

<data name="my_message" xml:space="preserve">
<value>This is first line &lt;br/&gt; This is my second line &lt;br/&gt;</value>
</data>

When i run mypage.cshtml , my line break char for the above string is not working . please help

The output I am getting is

This is first line <br/> This is my second line <br/>

I don't know why lines are not breaking I need an output as below

This is first line
This is my second line

回答1:

Try:

<p><span>@Html.Raw(HttpUtility.HtmlDecode(r.get("My_Message")))</span></p>