首页
>
ASP.NET > State Management in ASP.NET
State Management in ASP.NET
http://www.awprofessional.com/articles/ … 2&rl=1
Table 10-1: State Type Comparison in ASP.NET
|
Type of State
|
Scope of State
|
Advantages
|
Disadvantages
|
|
Application
|
Global to the application
|
- shared across all clients
|
- Overuse limits scalability
- Not shared across multiple machines in a Web farm
or processors in a Web garden
- Primary purpose subsumed by data cache in ASP.NET
|
|
Session
|
Per client
|
- Can configure to be shared across machines in a Web
farm and processors in a Web Garden
|
- Requires cookies or URL managing to mange client association
- Off-host storage can be inefficient
|
|
Cookie
|
Per client
|
- Works regardless of server configuration
- State stored on client
- State can live beyoond current session
|
- Limited memory (-4KB)
- Clients may not support cookies or may explicitly
disable them
- Stae is sent back and forth with each request
|
|
View
|
Across POST request to the same page
|
- Works regardless of server configuration
|
- State is retained only with POST request
made to the same page
- State is sent back and forth with each request
|