通过定时reload回发某页面请求 避免因用户一直不操作而引起的Session过期

调用定时回发页面的主框架页面的Left菜单页面:

HTML部分
=======

ContractedBlock.gif ExpandedBlockStart.gif Code
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><from>
/**/
<iframesrc="Message/RefreshMessage.aspx"height="0"runat="server"id="iframeRefresh"></iframe>
</form>

.cs部分
=======

ContractedBlock.gif ExpandedBlockStart.gif Code
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->protectedvoidPage_Load(objectsender,EventArgse)
{

if(Session["isRefresh"]!=null&&Session["isRefresh"].ToString()=="1")
{
this.iframeRefresh.Attributes["src"]="ReloadOnTime.aspx";
}
else
{
this.iframeRefresh.Attributes["src"]="OtherReloadOnTime.aspx";
}
}

定时回发页面ReloadOnTime.aspx

HTML部分
=======

ContractedBlock.gif ExpandedBlockStart.gif Code
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><%@PageLanguage="C#"AutoEventWireup="true"CodeFile="ReloadOnTime.aspx.cs"Inherits="ReloadOnTime"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>刷新Session</title>
</head>
<body>
<formid="form1"runat="server">
<asp:TextBoxID="hidtxt_isRefresh"runat="server"></asp:TextBox>
</form>
</body>
</html>
<scripttype="text/javascript"language='javascript'>
window.onload
=function()
{
if(document.all.hidtxt_isRefresh.value=="1")
{
window.setInterval(
"fn_BtnEventOnTime()",600000);
}
}
functionfn_BtnEventOnTime()
{
window.location.reload();
}
</script>

.cs部分
=======

ContractedBlock.gif ExpandedBlockStart.gif Code
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Collections;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;

publicpartialclassReloadOnTime:System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
//如果页面不让因用户不操作而过期
if(Session["isRefresh"]!=null)
{
if(Session["isRefresh"].ToString()=="1")
{
this.hidtxt_isRefresh.Text="1";
}
else
{
this.hidtxt_isRefresh.Text="0";
}
}
else
{
this.hidtxt_isRefresh.Text="0";
}
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值