ASP.NET MVC Html.Encode - New lines

后端 未结 5 1182
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-30 00:03

Html.Encode seems to simply call HttpUtility.HtmlEncode to replace a few html specific characters with their escape sequences.

However this

5条回答
  •  长发绾君心
    2020-12-30 00:35

        /// 
        /// Returns html string with new lines as br tags
        /// 
        public static MvcHtmlString ConvertNewLinesToBr(this HtmlHelper html, string text)
        {
            return  new MvcHtmlString(html.Encode(text).Replace(Environment.NewLine, "
    ")); }

提交回复
热议问题