Hi,
Most of us who
creates Web sites work with session. We use sessions to store user
specific data, so that it can be retrieved very easily.
You can read my earlier posts on sessions here.
A few interesting things about session in Asp.Net
Mystries of when does Session_End event fires in Asp.Net
Session and concurrent request
By default the
session data is stored in the process. But Asp.net Gives you two
options to store data outside the process State Server or SQL server.
Depending on various situations you might want to store the session
data in any of them. To store the session data Out of the process
(worker process), the data needs to be serialized.
Depending on the amount of data stored and the number of concurrent session this Serialized data can become very large.
With this size
problem in mind, Asp.Net 4.0 has come up with a new option for
compressing the Session Data when the session is stored out of process.
The setting can be made at the Web.config (Exmaple below) level, based
on which Asp.net 4.0 will itself compress and decompress the session
data using the System.IO.Compression.GZipStream class.
<sessionState mode="SqlServer" sqlConnectionString="conn" allowCustomSqlDatabase="true" compressionEnabled="true" />
(The extra change required in web.config file has been made Bold)
This compression
and Decompression of Session Data not only reduces the Session data for
concurrent sessions but also help reducing the size of data being
stored and retrieved on every request to the website.
But remember this
option should only be used in case you are storing lots of data in the
session. If you use this option while storing small amount of data in
the session then it will give negative effect as even for the small
amount of data, the GZip compression (and decompression) will have to
run every time.
Vikram