首页 > 代码库 > asp.net 设置网页过期

asp.net 设置网页过期

        /// <summary>        /// 判断网页是否过期        /// </summary>        /// <returns></returns>        private bool isPageExpired()        {            if (Session["TimeStamp"] == null ||               ViewState["TimeStamp"] == null)                return false;            else if (Session["TimeStamp"] == ViewState["TimeStamp"])                return true;            else                return false;        }
        protected void Page_Load(object sender, EventArgs e)        {            #region 判断网页是否过期            Response.Cache.SetCacheability(HttpCacheability.NoCache);            Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));            Response.Cache.SetNoStore();            Response.AppendHeader("Pragma", "no-cache");            if (Page.IsPostBack)            {                if (isPageExpired())                {                    Response.Redirect("expired.htm");                    return;                }                else                {                    Session["TimeStamp"] = DateTime.Now.ToString();                    ViewState["TimeStamp"] = DateTime.Now.ToString();                }            }            #endregion         }

 

asp.net 设置网页过期