3 April 2012

Session State Mode in Asp.net

Session State Mode in Asp.net

If your application needs to scale to thousands of users, then you should strongly consider
using the client for storing application state. Removing this burden from the server frees
up resources, allowing the server to process more user requests. ASP.NET provides several
techniques for storing state information on the client. These include the following:

View state ASP.NET uses view state to track values in controls between page requests.
You can also add your own custom values to the view state.
Control state Control state allows you to persist information about a control that is
not part of the view state. This is useful to custom control developers. If view state is
disabled for a control or the page, the control state will still function.
Hidden fields Like view state, HTML hidden fields store data without displaying that
data to the user’s browser. This data is presented back to the server and is available
when the form is processed.
Cookies A cookie stores a value in the user’s browser. The browser sends this value
with every page request to the same server. Cookies are the best way to store state
data that must be available for multiple webpages on a website.
Query strings A query string is a value that is stored at the end of a URL. These
values are visible to the user through his or her browser’s address bar. Use query
strings when you want a user to be able to use email or instant messaging to store
state data within a URL.

The following example shows settings in a Web.config file that cause the session state to
be stored in a SQL Server database identified by the specified connection string.
< configuration >
< system.web >
< sessionState
sqlConnectionString="Data Source=MySqlServer;Integrated Security=SSPI;"
stateNetworkTimeout="30" />

No comments:

Post a Comment

Comments Welcome