HTML.Encode but preserve line breaks

前端 未结 5 1228
甜味超标
甜味超标 2021-02-01 13:48

I take user input into a text area, store it and eventually display it back to the user.

In my View (Razor) I want to do something like this...

@Message.         


        
5条回答
  •  说谎
    说谎 (楼主)
    2021-02-01 14:17

    For those who use AntiXssEncoder.HtmlEncode

    As AntiXssEncoder.HtmlEncode encode the /r/n character to so the statement should be

    _mDraftMsgModel.wnItem.Description = AntiXssEncoder.HtmlEncode(draftModel.txtMsgContent, false).Replace("
    ", "
    ");

提交回复
热议问题