Asp.netCommon status management solutions include::
View statusView state
Hide domainHidden fields
Cookies
Query string
Application State
Session state
Profile
WhereView state, hidden fields, cookies, and query stringsSave the value in different ways on the client. WhileApplication State, session state, and ProfileThe value is saved on the server in different forms.
View status (View state)
View stateWill be automatically savedWebThe value of each element on the page, as long asEnableviewstate = true. viewstateStore element values in the form of key-value pairs.InAsp.netMedium, View StateThe value is stored in the page by hashing in the form of hidden fields.,Similar:
<Input type = "hidden" name = "_ viewstate" id = "_ viewstate" value = "/wepdwujnzgzndmwntmzzgtn7 + fhxsyxj2jnzu0uxkexceetrg ="/>
If you useView stateTo store data,The data size cannot exceedPageOfMaxpagestatefieldlengthDefined value.
Advantages:
No server resources required,BecauseView stateIs saved on the page,Therefore, you do not need to borrow resources from the server to save the value..
Ease of use,You can only save the value of an element in the form of a key-value pair..
SecurityView stateThe saved values are hashed and compressed.,ThereforeHidden fieldsSecurity.
Disadvantages:
Performance problems,BecauseView stateSave the value inPageMedium,Therefore, each time a page is loadedView stateSaved Value,This results in performance loss..
Security issues, althoughView stateThe saved values are hashed and compressed, butHidden fieldsIs still vulnerable to interception and exploitation by hackers.
Hide domain(Hidden fields):
This is oldASPOne way to save element values.UseHidden fieldsDepends on how the page submits data.Must PassPostMethod submission before obtainingHidden fieldsIf you useHTTPOfGetMethod,HiddenThe element value is invalid.
Hidden fieldsAnother feature is that it stores the element valuesHtmlCodeIs saved in plaintext. You can easily view the pageHtmlSource codeGetHidden fieldsElement value.
Advantages:
Easy to use,Wide application scope, supported by almost all browsers and client devicesHidden fieldsThis form.
Disadvantages:
Extremely insecure
Only simple data can be stored, suchStringType
Performance problems, useHiddenFieldsLikeView stateSimilarly, each page display will be loaded.
Cookies
CookiesIt is also a form of data storage on the client.CookiesData can be stored for a long time or temporarily, depending onCookies.CookiesThe corresponding scope is the wholeWebThe website, rather than a page, depends on the browser for management. If the browser on the client is disabledCookiesAnd cannot be enabled.CookiesSave data on the client.CookiesWhen a page request sends data to the server, its value can beRequest. Support for most browsersCookiesStorage Capability 4 m Bytes of data, and the browser can accommodateCookiesThe number is also limited. Generally, each site can generate a maximum20ItemsCookies.
ReadCookiesValue:
If (request. Cookies ["usersettings"]! = NULL)
{
String usersettings;
If (request. Cookies ["usersettings"] ["font"]! = NULL)
{Usersettings = request. Cookies ["usersettings"] ["font"];}
}
DirectionCookiesWrite value:
Response. Cookies ["usersettings"] ["font"] = "Arial ";
Response. Cookies ["usersettings"] ["color"] = "blue ";
Response. Cookies ["usersettings"]. expires = datetime. Now. adddays (1D );
Advantages:
You can configure the expiration time.
No need to occupy server resources
Easy to use
You can also maintain persistent data.
Disadvantages:
Size limit, which is supported by most browsers 4 m Bytes.
Restricted by user configuration. If the browser is disabledCookies,This function cannot be used.
Potential security risks. BecauseCookiesIt is stored in the client machine as a text file, althoughCookiesThe content is hashed, but can still be obtained and used by people.
Query string
The query string is on the pageURLSome parameters are added to this form to transfer values between pages. It provides a very convenient method for page value passing.
Shape:
Http://www.abc.com/list.asp? Id = 1098 & type = a100
Advantages:
Simple and Convenient,Widely used
Disadvantages:
Extremely insecure and necessaryUrlencodeAndUrldecodeProcess strings to enhance security.
The size is limited. Some browsers or client devices only support the length2083OfURLString.
Application State
Asp.netAllow youApplication StateStorage Value--It isHttpapplicationstateClass.Application StateProvides a global storage method that can beWebApplicationProgram.Application StateAndSession stateStore values in the form of key-value pairs.
Advantages:
Global range
Disadvantages:
Global range
Occupy server resources
Vulnerability, becauseApplication StateIs stored in the memory, so it will be lost when the application is stopped or restarted.
Poor scalability, cannot be shared among multiple servers or processors.
Session State
Session stateAndApplication StateA bit similar, but it acts on a browser session. If different users use your applicationSessionSession.Session stateIt is also a key/Store data in the form of value pairs.
Advantages:
Easy to use
Data Persistence, becauseAsp.netProvidedSessionOvercome the originalASPProcess dependency defects, you can setSessionStored in the database, soSessionThe data will never be lost.
NoCookiesYes.Asp.netCan be found inASP. NETClientSessionInformationCookielessStorage.
Disadvantages:
BecauseSessionVariables are stored on the server, so they occupy server resources.
Profile
ToProfileThe form of data storage isASP. net2.0A new feature. It stores information in the database, so it never loses information.
Advantages:
Data Persistence
Scalable
Disadvantages:
BecauseProfileThe data is stored in the database, so the following features exist,
Manual data maintenance,
Poor performance