RE: Client Connection
From: Mike Moore [MSFT] (michmo@online.microsoft.com)
Date: 12/06/02
- Next message: Aaron Margosis [MS]: "Re: User ASPNET in SQL Server 2000"
- Previous message: John Hermanson: "Re: URGENT: Why does the SessionID changes in every request?"
- In reply to: PPaps: "Client Connection"
- Next in thread: Ppaps: "Re: Client Connection"
- Reply: Ppaps: "Re: Client Connection"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: michmo@online.microsoft.com (Mike Moore [MSFT]) Date: Fri, 06 Dec 2002 03:42:36 GMT
Hi Paps,
I consider the following to be non-elegant since you have to leave a
browser open somewhere. I tried creating an infinite loop on the server,
using thread.sleep to pause between testing & purging the application
variables. However, it caused some problems during my testing (it hung the
application domain). So, I moved the timing function to the browser.
- Setup the following two pages
- Browse StoreDate1.aspx & click the button
This sets the application variable for the user and displays the results
- In a different browser window (even on a different machine), browse
StoreDate2.aspx & type "Erase" in the text box
This will post the page to the server every 10 seconds. On the server, it
will look for any application time stamps that are more than 15 seconds old
and delete the related application variables.
*** StoreDate1.aspx
Add two text boxes and a button
*** StoreDate1.aspx.vb
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
TextBox1.Text = Application(User.Identity.Name) & " -- " &
Application(User.Identity.Name & "_Time")
Catch
End Try
Dim d As Date = Now()
Application(User.Identity.Name) = "testing"
Application(User.Identity.Name & "_Time") = d
TextBox2.Text = d
End Sub
*** StoreDate2.aspx
Add a text box and this code:
<SCRIPT LANGUAGE="javascript">
window.setTimeout("Form1.submit()",10000);
</SCRIPT>
*** StoreDate2.aspx.vb
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If TextBox1.Text = "Erase" Then
Dim d As Date
Dim diff As Long
Dim s As String
Dim AppKeys() As String = Application.AllKeys
For Each s In AppKeys
Try
If "_Time" = Right(s, 5) Then
d = Application(s)
'For testing, make it 15 seconds
diff = DateDiff(DateInterval.Second, d, Now())
If diff > 15 Then
Application.Remove(Left(s, Len(s) - 5))
Application.Remove(s)
End If
End If
Catch
End Try
Next
Response.Write("Last cleanup was at " & Now().ToShortDateString &
" " & Now().ToLongTimeString & "<br>")
Else
Response.Write("NO cleanup<br>Last check was at " &
Now().ToShortDateString & " " & Now().ToLongTimeString & "<br>")
End If
End Sub
*** End of sample code
Thank you, Mike Moore
Microsoft, ASP.NET
This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
>Content-Class: urn:content-classes:message
>From: "PPaps" <papettip@euroforex.com>
>Sender: "PPaps" <papettip@euroforex.com>
>Subject: Client Connection
>Date: Thu, 5 Dec 2002 05:00:23 -0800
>Lines: 13
>Message-ID: <032701c29c5e$45c236d0$89f82ecf@TK2MSFTNGXA01>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="iso-8859-1"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Thread-Index: AcKcXkXCnfLEIJqZQpym5Up4GT69zQ==
>X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>Newsgroups: microsoft.public.dotnet.framework.aspnet.security
>NNTP-Posting-Host: TK2MSFTNGXA01 10.40.1.47
>Path: cpmsftngxa09!cpmsftngxa10!cpmsftngxa06
>Xref: cpmsftngxa09 microsoft.public.dotnet.framework.aspnet.security:3268
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security
>
>When a user logon to my web I save some information on a
>Application variable ex : Application[UserName] = MyInfo;.
>The user can of course open more then one session and the
>user information is also avaible in a WebService for
>other server that need this information.
>My problem is :
>When I can cancel this information becouse the user is
>logoff ?
>How I can understand when the user close all his
>sessions ?
>
>Hope you understand the problem (else let me know ;))
>Thanks Paps
>
- Next message: Aaron Margosis [MS]: "Re: User ASPNET in SQL Server 2000"
- Previous message: John Hermanson: "Re: URGENT: Why does the SessionID changes in every request?"
- In reply to: PPaps: "Client Connection"
- Next in thread: Ppaps: "Re: Client Connection"
- Reply: Ppaps: "Re: Client Connection"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]