aspx页面加一句<%@ OutputCache Duration="10000" VaryByParam="*"%>缓存10000秒相当于是静态了

解决方案 »

  1.   

    how are you creating those static pages? use a tool? add some special tags or comments like
    <!--start insert 1 --><!--end insert 1 --> inside those static pages and write a parser (using regular expression, for example) to insert information in those tags
      

  2.   

    我现在用的是
    StreamWriter outText = new StreamWriter(Server.MapPath(htmName),true,System.Text.Encoding.GetEncoding("GB2312"));可以在服务器上已经存在的html尾部添加内容,
    但我必须在倒数第8行添加内容,怎样实现呢?
      

  3.   

    >>>>倒数第8行is not a good criteria, like I said earlier, insert some placeholder like<!--PUTMYCONTENTHERE-->then replace it with whatever you wantotherwise, you need to read all the content in, count the number of lines, find where 倒数第8行 is, insert the content..., very tedious to do
      

  4.   

    谢谢saucer(思归, MS .NET MVP) ,我明白您的意思。
    我计划用StreamRead先把html文件读到一个string中,
    然后string.Replace("<!--PUTMYCONTENTHERE-->","新增加内容<!--PUTMYCONTENTHERE-->");然后把这个string写回html方法对头吧?
      

  5.   

    just try it, you will know if it is 对头 or not
      

  6.   

    NewHtml.Replace("<!--Add Reply-->",ReplyHtml+"<!--Add Reply-->");运行没有任何效果,替换无效。Replace是不是只能等长替换呢?
      

  7.   

    no,
    1. make sure you have <!--Add Reply--> in your html code2. string is immutableNewHtml = NewHtml.Replace("<!--Add Reply-->",ReplyHtml);