求大哥哥  大姐姐们  我急用  谢谢了

解决方案 »

  1.   

    关键字存持久化介质中,系统启动后读入内存。加过滤器,对每一提交,用正则进行匹配算法或者这种
    在网站后台设置过滤字符
    void Application_BeginRequest(object sender, EventArgs e)
    {
      for (int i=0; i < Request.Form.Count;i++)
      {
      if (Request.Form[i].ToString() == "__VIEWSTATE") continue;
      if (IsM(Request.Form[i].ToString()))
      {
      Response.Write("您提交的内容中含有非法字符.");
      Response.End();
      }  }  
    }
    protected bool IsM(string InText)
    {
      string word = @"";
      if (InText == null)
      return false;
      if (Regex.IsMatch(InText,word))
      return true;
      return false;
    }  
    Regex.Replace
    数据库,XML,List都可保存
      

  2.   

    我用的就是这个,当时头疼了很久的问题
     public static string changeStyle(string contents, DataTable dt)
            {
                //A标记中title中显示的文本改变样式
                string p = "";
                //获取到的关键词关联文章总数的记录条数
                int kcount = ArticleKeyWordsRules.getArticleCountAll().Rows.Count;
                //获取最热关键词的文章数量
                double max = Convert.ToDouble(ArticleKeyWordsRules.getArticleCountAll().Rows[0]["ArticleCount"]);
                //循环关键词列表
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string dtkey = dt.Rows[i]["KeyWords"].ToString().Trim();
                    if (contents.Contains(dtkey))
                    {
                        //根据关键词获取对应文章的总数量
                        int count = ArticleKeyWordsRules.getArticleCountByKeyWords(dtkey);
                        //取出替换前的关键词
                        string wordsBefore = dtkey;
                        //A标记中title显示的文本
                        p = wordsBefore;
                        //给A标记的title值进行改变,以免被替换掉
                        for (int j = 0; j < wordsBefore.Length; j++)
                        {
                            //j*5  添加的字符位置,等于后面的字符长度+1
                            p = p.Insert(j * 5, "|@#|");
                        }
                        //获取该关键词的值(绿色=蓝色=值)                    //double num = (1 - count / (max - min)) * 230;
                        ////把数字转换成int型的
                        //int number = St.CheckIntTypePageParameterNegative1(num.ToString());
                        //if (number == -1)
                        //{
                        //    number = 230;
                        //}
                        //int number = Convert.ToInt32(num);                    double num = (1 - count / max) * 230;
                        int number = Math.Abs(Convert.ToInt32(num));                    //确定该关键词的背景色
                        string color = "#FF" + DtoX(number) + DtoX(number);
                        //替换后的样式
                        string wordsAfter = "<a href=\"ArticleList.aspx?KeyWords=" + HttpContext.Current.Server.UrlEncode(wordsBefore) + "&currentPage=1\" title=\"关&nbsp;键&nbsp;词:" + p + " &#10;文章数量:" + count + "\" target=\"_blank\"><span style=\"background-color:" + color + ";\">" + wordsBefore + "</span></a>";
                        contents = contents.Replace(wordsBefore, wordsAfter);
                    }
                }
                //把|@#|替换掉
                contents = contents.Replace("|@#|", "");
                //返回内容
                return contents;
            }