• 我的静态页面


     protected override void Render(HtmlTextWriter writer)
        {
            try
            {
                DateTime dt = System.IO.File.GetLastWriteTime("index.html");
                TimeSpan ts = dt - DateTime.Now;
                if (ts.TotalHours > 1)
                {
                    System.IO.StringWriter html = new System.IO.StringWriter();
                    System.Web.UI.HtmlTextWriter tw = new HtmlTextWriter(html);
                    base.Render(tw);
                    System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("index.html"), false, System.Text.Encoding.UTF8);
                    sw.Write(html.ToString());
                    sw.Close();
                    tw.Close();
                    Response.Redirect("Index.html");
                }
                else
                {
                    Response.Redirect("Index.html");
                }
            }
            catch
            {
                System.IO.StringWriter html = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter tw = new HtmlTextWriter(html);
                base.Render(tw);
                System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("index.html"), false, System.Text.Encoding.UTF8);
                sw.Write(html.ToString());
                sw.Close();
                tw.Close();
                Response.Redirect("Index.html");
            }
           
        }
  • 相关阅读:
    Mysql基础3-数据操作语言DML-数据查询语言DQL
    Mysql基础2-数据定义语言DDL
    Mysql基础1-基础语法-字段类型
    php源码建博客5--建库建表-配置文件-错误日志
    PHP基础4--函数-数组
    php源码建博客4--实现MVC结构微型框架
    PHP基础3--文件加载-错误处理
    php源码建博客3--区分平台的MVC结构
    php源码建博客2--实现单入口MVC结构
    php源码建博客1--搭建站点-实现登录页面
  • 原文地址:https://www.cnblogs.com/future/p/1206275.html
Copyright © 2020-2023  润新知