1.

Describe Session Handling In A Webform, How Does It Work And What Are The Its Limits?

Answer»

Sometimes it is NECESSARY to carry a particular session data across PAGES, and HTTP is a stateless protocol. In order to maintain state between page calls, we could use cookies, hidden form fields etc. One of them is using sessions. each sessions are maintain a unique key on the server and serialize the data on it. Actually it is a hashtable and stores data on key/value pair of combination. You could set a session using Session Object and retrieve the same data/state by passing the key.

//Set
Session["abc"] = "Session Value";

// Get
string abc = Session["abc"].ToString();

The downside of sessions is scalability. Say your application gets more and more hits and you though instead of one webserver handling it, have it in a webform (multiple web servers working under one domain). You cannot transfer the session so easily across multiple webservers. it PHYSICALLY serializes the state data to webserver hard disk. .NET proposes a new way to handle this using a stateserver (actually a trimmed down sql server) storing the web session data in a factory configured database SCHEMA or using Database with your own schema defined to handle the sessions.

Sometimes it is necessary to carry a particular session data across pages, and HTTP is a stateless protocol. In order to maintain state between page calls, we could use cookies, hidden form fields etc. One of them is using sessions. each sessions are maintain a unique key on the server and serialize the data on it. Actually it is a hashtable and stores data on key/value pair of combination. You could set a session using Session Object and retrieve the same data/state by passing the key.

//Set
Session["abc"] = "Session Value";

// Get
string abc = Session["abc"].ToString();

The downside of sessions is scalability. Say your application gets more and more hits and you though instead of one webserver handling it, have it in a webform (multiple web servers working under one domain). You cannot transfer the session so easily across multiple webservers. it physically serializes the state data to webserver hard disk. .NET proposes a new way to handle this using a stateserver (actually a trimmed down sql server) storing the web session data in a factory configured database schema or using Database with your own schema defined to handle the sessions.



Discussion

No Comment Found