The first thing we need to do is create the base classes we will use in the rest of the application. The first base class is the XML Handler. This class will handle all the data in and out of the Session Object. So how do we do this? If you look in BaseClasses\BaseSessionStorage.cs you will see we are using two protected objects and a protected string:
protected XmlDocument _internalState;
protected HttpContext _httpContext;
private string _identifier;
Now that we have defined our objects we need to start dealing with them. _internalState is the actual XML object we use to handle all of our XML based tasks. _httpContext is an internal representation of the HTTP context the server deals with. And _identifier is the Session State key half of the Session State key/value pair. Whenever any object is instantiated that is inheriting from this object we want to make sure that the bare minimums are always instantiated. We do this by allowing only one constructor.
public BaseSessionStorage(HttpContext appContext, string Identifier, string BaseXml)
// Set internal objects and variables...
The above constructor guarantees we get the 3 elements we need to make this class work. The rest of this class is a Public Property to get the XML string and a small handful of Public Methods to Get and Set the values and to get a Count of XML Nodes.
This article is not meant to be an XML tutorial so I will not be going into the details of this base class. Suffice it to say that the XML handling is straight forward and works. Please feel free to step through it, tweak it if necessary and have fun with it.
With this base class we can now create the application classes that we will use in the Web Pages, Web Controls and Web Services.