/// <summary>
    /// string 扩展
    /// </summary>
    public static class StringExtends
    {
        /// <summary>
        /// 用于防止XSS的字符串转义
        /// </summary>
        /// <param name="txt"></param>
        /// <returns></returns>
        public static string SRUrlEncode(this string txt)
        {
            if (string.IsNullOrWhiteSpace(txt))
            {
                return txt;
            }

            return StringEncode.HtmlEncode(HttpUtility.UrlDecode(txt));
        }

        /// <summary>
        /// 判断字符串是否为空(null)或是内容为空
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static bool IsNullOrEmpty(this string str)
        {
            return string.IsNullOrEmpty(str);
        }
    }
View Code

相关文章:

  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2021-11-08
  • 2021-05-25
猜你喜欢
  • 2021-10-18
  • 2022-02-21
  • 2022-12-23
  • 2021-05-16
  • 2021-08-22
  • 2021-05-18
  • 2022-12-23
相关资源
相似解决方案