纯静态怎么生成?思路是什么? 有例子最好。 那么生成纯静态之后,怎么对数据进行交互。比如门户网站上的一个纯静态新闻页面,用户在新闻里面写评论。 

解决方案 »

  1.   

    制作静态模板(html)
    替换模板标签 
    生成静态页面
    数据交互JS+AJAX
      

  2.   

    “数据交互JS+AJAX”这一步骤有更具体的思路吗?
      

  3.   

    利用ajax 将输入的内容返回到服务端保存,就是这个过程。
    当然相关脚本与模板页一同生成。
      

  4.   

    纯静态可以减少大量的数据库交互,缓存交互,页面上的动态内容可以由ajax控制或者iframe嵌套aspx
      

  5.   

    你可以用JSON。JQuery+ASHX.这就可以实现静态的.完全脱离控件
      

  6.   


    直接 private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                string cription = "";
                myDt = cl.GetTable();//获取自己数据库中的一个table
                if (myDt.Rows.Count > 0)
                {
                    cription = myDt.Rows[0]["PUB_NAME"].ToString();
                }
                string title = "这是动态生成的静态页面";
                string dhtml = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//CN\"><html><head>" +
                 "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">" +
                 "<title>" + title + "</title></head><body >";
                dhtml += "<table >" +
                 "<tr><td  >" + title + "</td></tr><tr><td >" + cription + "</td></tr></table>" +
                 "</body></html>";
                string Filename = DateTime.Now.ToString("yyyyMMddHHmmss") + ".html";//动态的文件名
                string Filepath = Server.MapPath(@"~/");
                string Cname = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString();
                string Filecreatepath = Filepath + Cname + @"/";//页面要保存的路径            //动态生成的静态页面按年月保存本年本月的文件夹中
                if (Directory.Exists(Filecreatepath)) //判断当月的文件夹是否存在,
                {
                    //调用创建html静态页面方法
                    Create_html(Filecreatepath + Filename, dhtml);
                }
                else
                {
                    //创建页面保存到的文件夹
                    DirectoryInfo di = Directory.CreateDirectory(Filecreatepath);
                    Create_html(Filecreatepath + Filename, dhtml);
                }
            }
            catch (IOException ex)
            {
                throw ex;
            }
        }
        private void Create_html(string allfilename, string htmlcode)
        {
            FileStream CreateFile = new FileStream(allfilename, FileMode.CreateNew);
            StreamWriter sw = new StreamWriter(CreateFile);
            sw.WriteLine(htmlcode);//将拼好的Html代码写入页面中
            sw.Close();
            Page.RegisterStartupScript("", "<script>window.alert('The file created successfully.!')</script>");
          
        }
      

  7.   

    自我感觉用替换比较麻烦,有个方法直接可以找到静态代码,就类似“查看源代码”,然后直接将这些东西写到一个新html文件中。(仅供参考)
      

  8.   

    直接用ajax方法post当前页面到后台的某个专门处理评论的ashx来进行处理。