ASP.NET中防止Session过期

时间:2022-09-17 23:28:29
在所做页面加个Iframe:
<iframe id="fresh" src="Refresh.aspx" width="0" height="0"></iframe>
然后在Refresh.aspx代码如下:
<head runat="server">
    <title></title>
    <meta http-equiv="Refresh" content="600; url=Refresh.aspx" />    (表示定时600秒刷新到Refresh.aspx)
</head>
<body>
    <form id="form1" runat="server">
        <div>
        </div>
    </form>
</body>
</html>


  protected void Page_Load ( object sender,EventArgs e )
        {
            // 访问Session以防止Session过期
            Session["Refresh"] = string.Empty;
        
        }