B
Bob
Hi,
we have an intranet application where users can join a forum and post a
message. The user first must choose a nickname. There are 'normal' pages and
pages which use the clientcallback method, in order to refresh the list of
active users into a forum.
I use a session variable in this application and i set the timeout = 15
(minutes) in the web.config.
What i try to do is: when the session expires (the user has done nothing for
15' so the value of session("nickname") is then empty), and the user tries
to access any page, anywhere the user is he must be redirected to the start
page for chosing again a nickname. In all pages, i added this code (in
code-behind):
If Session("nickname") = "" Then
Response.Redirect("start.aspx")
End If
This works fine ... except for pages with clientcallback. In this case, the
session never expires, because something is sent to/from the server every 2
seconds.
So, how can i close the session (= how to remove the value of session
variable) when the user stops any activity during 15' while he is on a page
with clientcallback?
Thanks
Bob
See the code in the aspx file:
<script type="text/javascript">
setInterval('refresh();',2000);
function refresh()
{
CallServer('', null);
}
function Retour(mess, context)
{
var obj = document.getElementById("<%= Label1.clientID %>");
obj.innerText = mess;
}
and in code-behind: (part of it)
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
If Session("nickname") = "" Then
Response.Redirect("start.aspx")
Else
Dim cm As ClientScriptManager = Page.ClientScript
Dim cbReference As String
cbReference = cm.GetCallbackEventReference(Me, "arg", _
"Retour", "")
Dim callbackScript As String = ""
callbackScript &= "function CallServer(arg, context)" & _
"{" & cbReference & "; }"
cm.RegisterClientScriptBlock(Me.GetType(), "CallServer", _
callbackScript, True)
End If
End Sub
we have an intranet application where users can join a forum and post a
message. The user first must choose a nickname. There are 'normal' pages and
pages which use the clientcallback method, in order to refresh the list of
active users into a forum.
I use a session variable in this application and i set the timeout = 15
(minutes) in the web.config.
What i try to do is: when the session expires (the user has done nothing for
15' so the value of session("nickname") is then empty), and the user tries
to access any page, anywhere the user is he must be redirected to the start
page for chosing again a nickname. In all pages, i added this code (in
code-behind):
If Session("nickname") = "" Then
Response.Redirect("start.aspx")
End If
This works fine ... except for pages with clientcallback. In this case, the
session never expires, because something is sent to/from the server every 2
seconds.
So, how can i close the session (= how to remove the value of session
variable) when the user stops any activity during 15' while he is on a page
with clientcallback?
Thanks
Bob
See the code in the aspx file:
<script type="text/javascript">
setInterval('refresh();',2000);
function refresh()
{
CallServer('', null);
}
function Retour(mess, context)
{
var obj = document.getElementById("<%= Label1.clientID %>");
obj.innerText = mess;
}
and in code-behind: (part of it)
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
If Session("nickname") = "" Then
Response.Redirect("start.aspx")
Else
Dim cm As ClientScriptManager = Page.ClientScript
Dim cbReference As String
cbReference = cm.GetCallbackEventReference(Me, "arg", _
"Retour", "")
Dim callbackScript As String = ""
callbackScript &= "function CallServer(arg, context)" & _
"{" & cbReference & "; }"
cm.RegisterClientScriptBlock(Me.GetType(), "CallServer", _
callbackScript, True)
End If
End Sub