Introduction
ASP.NET provides state management facilities at four levels: application, session, page, and request.
The widely used application state methods are LOCK and UNLOCK.
Application["MyValue"] = 1;
Application.Lock();
int val = (int) Application["MyValue"];
if (val < 10)
Application["MyValue"] = val + 1;
Application.UnLock();
The Session class provides a dictionary-based model of storing
and retrieving session-state values.The Default Session State types are
In-Proc:Stores data as live objects in the ASP.NET Cache.
State-Server:Stores data as serialized objects to the memory of a Windows
service named aspnet_state.exe.
Sql-Server:Stores data as serialized objects into a SQL Server database.
ASP.NET pages supply the ViewState
property to let applications build a call context and retain values
across two successive requests for the same page. The view state
represents the state of the page when it was last processed on the
server. The state is persisted—usually, but not necessarily, on the
client side—and is restored before the page request is processed.
ViewState["Name"] = Jennifer;
//For Finding ViewState Length,
function ShowViewStateSize()
{
var buf = document.forms[0]["__VIEWSTATE"].value;
alert("View state is "+ buf.length + "bytes");
}
We can disable viewstate,
<% @Page EnableViewState="false" %>
<asp:datagrid runat="server" EnableViewState="false">
...
</asp:datagrid>
Happy Coding.
Comments are closed.