
404
|
Chapter 19: The HttpSessionState Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Comments/Troubleshooting
Understanding both the scope and the lifetime of the Session collection for a given
user is important when using the Session object. As mentioned above, a new session
is created when a user first requests a page within an ASP.NET application for which
session state is enabled (session state is enabled by default in in-process mode) and
that stores a value in the Session collection. The boundary of that ASP.NET applica-
tion is defined by the boundary of an IIS application. That is, the boundary of the
ASP.NET session includes all ASP.NET pages within a single IIS application and all
of its subfolders and virtual directories. It does not, however, include subfolders
that are defined as IIS applications. Figure 19-1 illustrates the different folder types
in IIS. In Figure 19-1, the SessionWrite.aspx file writes a value to the Session collec-
tion. Because the folder containing SessionWrite.aspx is a virtual directory that is a
part of the Chapter_19 application folder and is not defined as its own folder, the
session value written by SessionWrite.aspx will be available to any page in either
the Chapter_19 folder or the SubApp subfolder. If, however, the SubApp folder is
configured as an IIS Application (by accessing