troubleshooting Question

Display Session Timeout message before Session expires in ASP.Net having masterpage and iframes?

Avatar of Saroj13
Saroj13 asked on
17 Comments1 Solution1297 ViewsLast Modified:

I am having masterpage and using iframes. Everything is working fine except if submit activity happens on iframes, its not reseting the session timeout?

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="AdminMasterPage.master.cs" Inherits="CoreTeamFeedback.Administration.MasterPage" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">

   <asp:ContentPlaceHolder id="head" runat="server">
    <form id="form1" runat="server">
                 <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
       <span style="visibility:hidden">Session Idle:</span><span id="secondsIdle" style="visibility:hidden">&nbsp;seconds.</span>
           <asp:LinkButton ID="lnkSession" runat="server" />
<asp:ModalPopupExtender ID="mpeTimeout" BehaviorID ="mpeSessionTimeout" runat="server" PopupControlID="pnlPopup" TargetControlID="lnkSession"
   OkControlID="btnOK"  BackgroundCssClass="modalBackground"  >

<asp:Panel ID="pnlPopup" runat="server" CssClass="modalPopup" Style="display: none" >
        <div class="footer" align="right">
        <asp:Button ID="btnOK" runat="server" Text="OK" CssClass="Savebutton" CausesValidation="false" />
       <div id="mainContent">
        <asp:ContentPlaceHolder id="MainContent" runat="server"  >      

protected void Page_Load(object sender, EventArgs e)
    if (!this.IsPostBack)
        Session["Reset"] = true;
        Configuration config = WebConfigurationManager.OpenWebConfiguration("~/Web.Config");
        SessionStateSection section = (SessionStateSection)config.GetSection("system.web/sessionState");
        int timeout = (int)section.Timeout.TotalMinutes * 1000 * 60;
        ClientScript.RegisterStartupScript(this.GetType(), "SessionAlert", "SessionExpireAlert(" + timeout + ");", true);

Default.aspx   main page
              <frameset rows="20%,80%" frameborder="0"  >
            <frame name="topFrame" scrolling="no" frameborder="0" src="top.aspx">
            <frame name="mainFrame" scrolling="yes" src="bottom.aspx" DESIGNTIMEDRAGDROP="7">


<script type="text/javascript">
function SessionExpireAlert(timeout) {
    var seconds = timeout / 1000;
    document.getElementsByName("secondsIdle").innerHTML = seconds;
    document.getElementsByName("seconds").innerHTML = seconds;
    setInterval(function () {
        document.getElementById("seconds").innerHTML = seconds;
        document.getElementById("secondsIdle").innerHTML = seconds;
    }, 1000);
    setTimeout(function () {
        //Show Popup before 20 seconds of timeout.
    }, timeout - 20 * 1000);
    setTimeout(function () {
        window.location = "Expired.aspx";
    }, timeout);


What to do if there is any activity in top and right frame, it will reset the session timeout without refreshing the full page? If parent page refreshes, everything is working fine?
Join our community to see this answer!
Unlock 1 Answer and 17 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros