Re: Client Connection
From: Mike Moore [MSFT] (michmo@online.microsoft.com)
Date: 12/06/02
- Next message: StrongAuth, Inc. Newsletter: "Preparing to deal with California's Senate Bill 1386"
- Previous message: Ppaps: "Re: Client Connection"
- In reply to: 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 20:28:14 GMT
Hi Paps,
I meant that as a "sample". In actual usage I wouldn't run this very often.
Certainly not every 15 seconds. Pardon me for not explaining that.
Session variables are set to be cleared after a certain number of minutes
with no activity from that user. As you pointed out, this is on a "per
session" basis. Therefore, you cannot use the Session_OnEnd event to clear
your application variables for that particular user.
With my setup, the application level time stamp for the user represents the
most recent activity from ANY session owned by that user. So, if the
application level user time stamp is older than the time-out period for
session variables, then you know that this particular user's sessions are
all dead and it's time to erase the application variables.
* How often to trigger the purge process:
I wouldn't do it more often than once every 10 minutes. If your session
timeout period is more than 20 minutes, then you might do it even less
often. If I had my session timeout set to 60 minutes, I'd run the purge
process once every 20 to 30 minutes.
* Age to use to decide to purge old entries
In practice, there's a bit of a delay between when sessions time-out and
when they're cleaned up. I'd add some extra time to the session time-out
and use that as my time-out for the application level variables.
Personally, I'd add at least 10 minutes, but not more than one half the
number of minutes set as the session time-out period. If I had my session
timeout set to 60 minutes, I'd set my purge function to purge entries older
than 70 minutes.
Thank you, Mike Moore
Microsoft, ASP.NET
This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
>From: "Ppaps" <papettip@euroforex.com>
>References: <032701c29c5e$45c236d0$89f82ecf@TK2MSFTNGXA01>
<Qn$AEmNnCHA.2304@cpmsftngxa06>
>Subject: Re: Client Connection
>Date: Fri, 6 Dec 2002 16:01:59 +0100
>Lines: 134
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
>Message-ID: <udMpAiTnCHA.2408@TK2MSFTNGP10>
>Newsgroups: microsoft.public.dotnet.framework.aspnet.security
>NNTP-Posting-Host: 151.99.166.162
>Path: cpmsftngxa09!cpmsftngxa10!tkmsftngp01!TK2MSFTNGP10
>Xref: cpmsftngxa09 microsoft.public.dotnet.framework.aspnet.security:3284
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.security
>
>Hi Mike
>
>I've got 2 question 4 u.
>1) In this way could happen that the "StoreDate2" page erase the data of an
>active connection ? (in this case the user that is browsing should be
>reconfigured)
>2) could a Form Post every 10 or 15 Seconds decrease the WebServer
>Performance ?
>
>Thanks
>Paps
>
>
>"Mike Moore [MSFT]" <michmo@online.microsoft.com> wrote in message
>news:Qn$AEmNnCHA.2304@cpmsftngxa06...
>> 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: StrongAuth, Inc. Newsletter: "Preparing to deal with California's Senate Bill 1386"
- Previous message: Ppaps: "Re: Client Connection"
- In reply to: Ppaps: "Re: Client Connection"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]