Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

how to check end of session with clientcallback page?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob - 05 Dec 2007 16:36 GMT
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
Patrice - 05 Dec 2007 16:46 GMT
You could perhaps store the last user (not callback) activity date/time in a
session variable instead of just the nickname. This way you should be able
to don't send the refresh once the timeout is elapsed to let the session die
(or you could force the session expiration when the first callback wihtout
recent user activity occurs).

(basically this is you that handles the session expiration).

--
Patrice

> Hi,
>
[quoted text clipped - 62 lines]
>        End If
>    End Sub
bruce barker - 05 Dec 2007 17:19 GMT
if you are using cookie based sessions, client callbacks do not update the
session timer on the client, as the cookie is not updated and the client will
stop sending it after the timeout.

-- bruce (sqlwork.com)

> Hi,
>
[quoted text clipped - 62 lines]
>         End If
>     End Sub
Bob - 05 Dec 2007 20:43 GMT
Hi thanks for replying..

i added this in web.config: <sessionState mode="InProc" timeout="15"
cookieless="false">

As test, i started a page with client callback and waited 15'. After that i
tried to navigate to another page and, instead of being redirected to
start.aspx, i accessed that another page. When i do the same test but
starting from a 'normal' page (without client callback), i'm redirected to
start.aspx.
So, unless i do something wrong or i forgot to do something, the cookie
based sessions doesn't work either ...
Thanks

> if you are using cookie based sessions, client callbacks do not update the
> session timer on the client, as the cookie is not updated and the client
[quoted text clipped - 78 lines]
>>         End If
>>     End Sub
Bob - 06 Dec 2007 21:59 GMT
Hi Bruce,

can you give some comments about my last message, please?
Thanks

> if you are using cookie based sessions, client callbacks do not update the
> session timer on the client, as the cookie is not updated and the client
[quoted text clipped - 78 lines]
>>         End If
>>     End Sub

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.