Академический Документы
Профессиональный Документы
Культура Документы
NET
Objectives
View State:
The ViewState property provides a dictionary object for
retaining values between multiple requests for the same page.
When the page is processed, the current state of the page and
controls is hashed into a string and saved in the page as a
hidden field.
When the page is posted back to the server, the page parses
the view-state string at page initialization and restores property
information in the page.
To specify the maximum size allowed in a single view-state
field, you can use the property,
System.Web.UI.Page.MaxPageStateFieldLength.
In addition to the contents of controls, the ViewState property
can also contain some additional information:
ViewState[“color”] = “Yellow” ;
Control State:
The ControlState property allows you to persist property
information that is specific to a control.
This property cannot be turned off at a page level as can the
ViewState property.
Hidden Form Fields:
ASP.NET provides the HtmlInputHidden control, which
offers hidden-field functionality.
A hidden field does not render visibly in the browser.
The content of a hidden field is sent in the HTTP form
collection along with the values of other controls.
Cookies:
Cookies are stored either in a text file on the client file system
or in memory in the client browser session.
They contain site-specific information that a server sends to
the client along with the page output.
When the browser requests a page, the client sends the
information in the cookie along with the request information.
The server can read the cookie and extract its value.
Query Strings:
Query string is a piece of information that is appended to the
end of a page URL.
You must submit the page by using an HTTP GET command
to ensure availability of these values.
Application State:
Application state is an instance of the
System.Web.HttpApplicationState class.
It allows you to save values for each active Web application.
Application state is stored in a key/value dictionary that is
created during each request to a specific URL.
It is a global storage mechanism that is accessible from all
pages in the Web application.
It supports the following events:
Application.Start
Application.End
Application.Error
The handlers for the preceding events can be defined in the
Global.asax file.
Session State:
Session state is an instance of the
System.Web.SessionState.HttpSessionState class.
It allows you to save values for each active Web application
session.
It is similar to application state, except that it is scoped to the
current browser session.
It supports the following events:
Session.Start
Session.End
The handlers for the preceding events can be defined in the
Global.asax file.
InProc Mode:
This is the default mode.
Session state data is stored in memory on the Web server
within the process that is running the Web application.
This is the only mode that supports the Session.End event.
Session state information will be lost if application is restarted.
Session state cannot be shared between multiple servers in a
Web farm.
To enable InProc mode, the following markup can be added
within the <system.web> tags in the Web.config file:
<sessionState mode=“InProc”></sessionState>
Client Server
Request first page
Request received
Sliding Expiration:
This method specifies a duration for which an item can lie
unused in the cache.
The caching system can scavenge the item if it has not been
used for a duration that exceeds this value.
To add an item to the cache with a sliding expiration of 10
minutes, the following code snippet can be used:
Cache.Insert("CacheItem", "Cached Item Value", null,
System.Web.Caching.Cache.NoAbsoluteExpiration,
new TimeSpan(0, 10, 0));