> 1. How should I handle the session as the client will post one request
after
antoher (for may be consequtively 5 requests) ?
There are many ways to handle sessions. One way is the Session object,
which is by far the easiest method. You can (if required) store
information about the current session:
Session["MyVar"] = "MyValue";
And retrieve it later like this:
string sMyVar = Convert.ToString( Session["MyVar"] );
Using the session object is slightly less scalable (or slightly more
difficult to port to a server farm.)
2. Is there any way to 'cache' the database connection and reuse it for
subsequent request from the same client ?
It might sound like a good idea to store the database connection in the
Session object, but that's really one of the worst things one can do. The
session object lingers around for 20 minutes after the last HTTP request,
so that would basically swamp your database with connections.
Database connection caching (usally called "pooling") is implemented in
the framework. Connections with different credentials (username/password)
are pooled separately. So in effect, what you are asking for happens
automatically!
Greetings,
Wessel