Do this in web.config
<system.web>
<!--Profile enabled = false to for VISTA/IIS7-->
<profile enabled="false"></profile>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
Visual Basic options:
Set strict="true" to disallow all data type conversions
where data loss can occur.
Set explicit="true" to force declaration of all variables.
-->
<!--Setting Session State expiry-->
<!--
Handling Session Timeout
Rest implemented in page_load() of Timeout_Check.aspx and <body> of data_entry_form.aspx
Set to less than 6 mins of less because thats what IIS connection timeouts of different sorts are by default
and a higher value will be overridden by IIS.
-->
<sessionState timeout="6"/>
In data_entry_form.aspx
<body style="color: black;margin-left:0px; margin-top:0px;margin-bottom:0px;margin-right:0px" bgcolor="#000000" >
<form id="form1" runat="server">
<%--Handling Session Timeout
Adding invisible iframe to refresh if 10 seconds are left to session timeout
The end result is that the session will be reloaded on expiry without refreshing
the page, since the other part of the code is placed in page_laod of Timeout_Check.aspx
and so only that iframe would be reloaded, thus refreshing the session variables without whole
page refreshing.
Rest implemented in <system.web> of web.config and page_load() of Timeout_Check.aspx--%>
<iframe id="Timeout_Check" src="Timeout_Check.aspx" frameborder="0" width="0" height="0" runat="server"></iframe>
<div>
In Timeout_Check.aspx.vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
REM Handling Session Timeout
REM Adding header to refresh if 60 seconds are left to session timeout
REM Rest implemented <system.web> of web.config and and in <body> of calling parent (data_entry_form.aspx) aspx
REM The Session.Timeout converts the minutes into seconds.
REM The DateTime.Now.Ticks lets a new value be appended with the querystring to ensure that the browser does not cache and actually
REM send the URL because of its unique value, since seconds in time will always be progressing.
Response.AddHeader("Refresh", Convert.ToString((Session.Timeout * 60) - 60) & ";url=Timeout_Check.aspx?q=" & DateTime.Now.Ticks)
End Sub
In temperroradmin.aspx page_load()
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
REM Show alert if it was a delete error
Dim tempStrAndErrCompDELETE As Boolean
tempStrAndErrCompDELETE = Request.QueryString("request_tempMsg").ToString.Contains("DELETE")
If (tempStrAndErrCompDELETE = True) Then
REM NOTE: This is unneccessary now since its handled in page_error of data_entry_form.aspx using session("Delete_Error")
ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "Delete_Error", "alert('The DELETE operation could not be completed. This was because the record you tried to delete is already being used. If a record is already being used in another table then deleting it would also delete its entry from there and that would create null references. For further explanation of this please contact Saad Hashmi, Asst. IT Programmer.');", True)
REM Since the popup alert did not get displayed therefore adding a timer to response redirect for 0 seconds.
REM The reason for response redirect in first place is because multiple records were being added on refresh.
Response.AddHeader("REFRESH", "0;Data_Entry_Form.aspx")
Else
REM ...Continuing with other errors
Dim tmp_lbl_ErrorLabel As Label
tmp_lbl_ErrorLabel = CType(FindControl("ErrorLabel"), Label)
tmp_lbl_ErrorLabel.Text = Request.QueryString("request_tempMsg")
REM Checking for Session Timeout
REM In case connection was lost.
If Session("Login") = Nothing Then
tmp_lbl_ErrorLabel.Text = "Session has timed out."
End If
End If
End Sub
Session timing out because of conflict with IIS timeout
http://forums.asp.net/t/1411523.aspx
If IIS its 60mins ans web.config 20mins then actual timeout 20mins
If IIS its 60mins ans web.config 180mins then actual timeout 60mins
No comments:
Post a Comment