473,508 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

StateServer - when is the session serialised?

I'm currently using InProc session which are working fine. In the app, I've
got a master object called MyApp which has a fair number of properties,
child classes etc. I find it easier to do this:

Dim MyApp As New Beer.App
Session("App") = MyApp

And then do all programming against MyApp, e.g. MyApp.Property1 = SomeValue.
Means that I can work against pure objects and not the session deep in the
business layers.

Works a treat with InProc but my host (WebHost4Life) is starting to annoy by
a) setting the idle timer on the application to just 20 minutes or b)
reducing it down even more when they feel like it the result of which is
that the application shuts down sometimes as little as 5 minutes after the
last request which means the user session also gets discarded so all their
current session settings get lost.

WebHost4Life have suggested looking at StateServer as they support that. I
understand how this works, i.e. the session state is serialised into a
binary stream and stored in a separate process.

My question is *when* does this happen. I suspect it's *not* everytime you
write to Session but at some other point in the page lifecycle. Consider:

Dim Person1 As New Beer.Person
Person1.Name = "Rob"
Session("Person") = Person1
Person1.Name = "Fred"
Dim Person2 As Beer.Person = Session("Person")
Label.Text = Person2.Name

This displays "Fred" on the screen so I'm assuming that Session("Person") is
simply setting up the usual name/value pair with a reference to Person1 and
that:

Dim Person2 As Beer.Person = Session("Person")

Is getting the same reference to Person1 back out of the Session.

So I assume the serialisation occurs at some later stage?

Cheers, Rob.
Jul 3 '08 #1
3 1585
It makes sense to do that at the beginning/end of each request plus the
documentation is generally much better than sometimes reported and should
IMO always be searched
(http://www.google.com/search?hl=en&q...=Google+Search
and this is the second entry) before posting.

From http://msdn.microsoft.com/en-us/libr...83(VS.71).aspx :

Instead of keeping live objects, the .NET State Server simply stores session
state in memory when in out-of-proc mode. In this mode the worker process
talks directly to the State Server. In SQL mode, session states are stored
in a SQL Server database and the worker process talks directly to SQL. The
ASP.NET worker processes are then able to take advantage of this simple
storage service by serializing and saving (using .NET serialization
services) all objects within a client's Session collection at the end of
each Web request. When the client revisits the server, the relevant ASP.NET
worker process retrieves these objects from the State Server as binary
streams, deserializes them into live instances, and places them back into a
new Session collection object exposed to the request handler.
--
Patrice

Jul 3 '08 #2
there are three relevent events events in the request life cycle.

AcquireRequestState - load session
ProcessRequest - page life cycle
ReleaseRequestState - save session
-- bruce (sqlwork.com)
"Rob Nicholson" wrote:
I'm currently using InProc session which are working fine. In the app, I've
got a master object called MyApp which has a fair number of properties,
child classes etc. I find it easier to do this:

Dim MyApp As New Beer.App
Session("App") = MyApp

And then do all programming against MyApp, e.g. MyApp.Property1 = SomeValue.
Means that I can work against pure objects and not the session deep in the
business layers.

Works a treat with InProc but my host (WebHost4Life) is starting to annoy by
a) setting the idle timer on the application to just 20 minutes or b)
reducing it down even more when they feel like it the result of which is
that the application shuts down sometimes as little as 5 minutes after the
last request which means the user session also gets discarded so all their
current session settings get lost.

WebHost4Life have suggested looking at StateServer as they support that. I
understand how this works, i.e. the session state is serialised into a
binary stream and stored in a separate process.

My question is *when* does this happen. I suspect it's *not* everytime you
write to Session but at some other point in the page lifecycle. Consider:

Dim Person1 As New Beer.Person
Person1.Name = "Rob"
Session("Person") = Person1
Person1.Name = "Fred"
Dim Person2 As Beer.Person = Session("Person")
Label.Text = Person2.Name

This displays "Fred" on the screen so I'm assuming that Session("Person") is
simply setting up the usual name/value pair with a reference to Person1 and
that:

Dim Person2 As Beer.Person = Session("Person")

Is getting the same reference to Person1 back out of the Session.

So I assume the serialisation occurs at some later stage?

Cheers, Rob.
Jul 3 '08 #3
services) all objects within a client's Session collection at the end of
each Web request. When the client revisits the server, the relevant
ASP.NET worker process retrieves these objects from the State Server as
binary streams, deserializes them into live instances, and places them
back into a new Session collection object exposed to the request handler.
Thanks for that - despite me rushing when writing the original post which on
re-reading wasn't too clear. This is what I suspected/hoped happened - the
session is only serialised once at the start/end of the request which means
that you can work in the same way as inproc in terms of the objects you've
placed in the session.

Cheers, Rob.
Jul 3 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
6941
by: ACaunter | last post by:
Hi all, I was wondering how i could write some code which would automatically open the Login Page once the session has expired? -- AdamPC@hotmail.com
0
879
by: dee | last post by:
Hi, How can I change the error page I get when the session has expired and the next action is accessing a session state? Thanks Dee
0
1022
by: user2008 | last post by:
Hi all, My application tracking visitor by save several information once in Session_Start global event then store recorded row ID in session variable. Unfortunately, in Session_End global event,...
1
2741
by: leovega | last post by:
Hello, My aplication starts with a simple login window (login_page.aspx). Once the login/password is validated I redirect to an html which contains 3 frames. (mywebsite.html) The web site I...
0
900
by: kramprasad | last post by:
hi friends, In asp how to redirect to a login page when session is loss or expire.
15
13365
by: plsHelpMe | last post by:
Hi All, I am having a problem. I am using DOJO toolkits to fetch some data on my webpage. Now suppose if i leave my webpage for some time and the session gets expired and then i try to click on...
4
2013
by: agarwalsunitadhn | last post by:
my problem is that after every 20minutes i got the error that the Object reference not set to an instance of an object. and highlight the line lblWelcome.Text = "Welcome, " +...
0
899
by: dihola | last post by:
Hi, I have a problem with an ASP.NET C# application. When the session expires and then the user tries to access any page in the browser, instead of being transferred to the login page the website...
3
3223
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
I have a asp.net app. When session is invalid, how to redirect user to the login page? I don't want to add the code to redirect user to the login page into every page. Thanks, -Billy
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7328
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7049
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5055
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
422
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.