博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
页面内嵌iframe 防止session过期
阅读量:4968 次
发布时间:2019-06-12

本文共 1341 字,大约阅读时间需要 4 分钟。

If you are trying to stop the session from timeing out all the time you can do this rather than increasing the session timeout.

KeepAlive.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KeepAlive.aspx.cs" Inherits="Pages.KeepAlive" %>  <%@ OutputCache Location="None" VaryByParam="None" %>      
KEEP ALIVE

Keep Alive.aspx.cs

using System;using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Pages { ///  /// Page to keep the session alive ///  public partial class KeepAlive : System.Web.UI.Page { //- EVENTS ------------------------------------------------------------------------------------------------------------------ #region Events ///  /// Page Load ///  /// object /// args protected void Page_Load(object sender, EventArgs e) { try { //Add refresh header to refresh the page 60 seconds before session timeout Response.AddHeader("Refresh", Convert.ToString((Session.Timeout * 60) - 60)); } catch (Exception) { throw; } } #endregion Events //--------------------------------------------------------------------------------------------------------------------------- } }

Then in your master page create an iFrame that refreshes to keep the session alive

转载于:https://www.cnblogs.com/sherlock99/p/4040847.html

你可能感兴趣的文章
2018 Multi-University Training Contest 10 - Count
查看>>
HDU6203 ping ping ping
查看>>
《人人都是产品经理》书籍目录
查看>>
如何在git bash中运行mysql
查看>>
OO第三阶段总结
查看>>
构建之法阅读笔记02
查看>>
DataTable和 DataRow的 区别与联系
查看>>
检索COM 类工厂中CLSID 为 {00024500-0000-0000-C000-000000000046}的组件时失败
查看>>
mysql数据库中数据类型
查看>>
Fireworks基本使用
查看>>
Linux 标准 I/O 库
查看>>
.net Tuple特性
查看>>
Java基础常见英语词汇
查看>>
nginx启动、关闭命令、重启nginx报错open() "/var/run/nginx/nginx.pid" failed
查看>>
BZOJ 3097 Hash Killer I
查看>>
UINavigationController的视图层理关系
查看>>
html阴影效果怎么做,css 内阴影怎么做
查看>>
宏观经济
查看>>
综合练习:词频统计
查看>>
BZOJ1026: [SCOI2009]windy数
查看>>