passing a string with line break on to a cshtml pa

2019-07-23 13:46发布

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条回答
迷人小祖宗
2楼-- · 2019-07-23 14:07

Try:

<p><span>@Html.Raw(HttpUtility.HtmlDecode(r.get("My_Message")))</span></p>
查看更多
登录 后发表回答