There are a huge number of articles and blog posts on persisting data between user requests in ASP.NET. However, the ASP.NET Web Pages framework introduces a couple of additional mechanisms so this article explores those, as well as reviewing some of the standard approaches already available to Web Pages developers from other parts of the ASP.NET framework.
I'll begin by clarifying the problem that needs to be solved: HTTP is a stateless protocol. Being stateless, there is no requirement placed on HTTP (Web) Servers to retain information about each request or user, so by default, multiple requests from the same user are treated as a series of individual unconnected requests. In fact, the server has no concept of a "user" as such. If you want to manage user or application-related data over a number of requests, you have to implement strategies for managing that yourself. This article explores a number of client and server side options that ASP.NET offers to help facilitate this for the Web Pages developer:
- Hidden Form Fields
- Query Strings
- UrlData
- Cookies
- Session Variables
- Application Variables
- Cache
Each of the mechanisms provided by the ASP.NET Web Pages framework for managing this problem has its pros and cons as you will see.
No comments:
Post a Comment