Maintaining Session State
The main thing to understand here is that Web Forms (or the code behind the Web Forms) have to execute each time a request comes from the user. They process the request and then terminate. This makes things like module-level variables unusable for storing data that must persist for the entire session. Ah! A new word, session. Web applications use something called session state to maintain context between requests. The session state is maintained by IIS itself, so we don’t have to worry about the program terminating and losing its data.
The session exists outside the memory space of the executing code, so it is not lost. There is an intrinsic object called the Session object that is accessible from any Web Form’s code ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access