When you store information using a key based storage mechanism, such as is provided by the 'Session' and 'ViewState' objects, you want to avoid referencing these directly by key name, as this means all references to the data need to be casted, leaving you liable to invalid cast exceptions, it means it is up to the developer to remember the key names and also leaves you liable to typos, spelling mistakes and accidental re-use of the same key more than once. The first step to solving this problem is to create a strongly typed representation of the data, using classes and properties and then have those properties simply persist their data to/from the chosen data store. As a very basic example, lets say you want to ask a user for their name and age and store it in the Session.
Namespace Example.SessionObjects
    Public Class CurrentUserDetails
        Public Shared Property Name() As String
            Get
                Return CStr(HttpContext.Current.Session("CurrentUserName"))
            End Get
            Set(ByVal value As String)
                HttpContext.Current.Session("CurrentUserName") = value
            End Set
        End Property

        Public Shared Property Age() As Integer
            Get
                Return CInt(HttpContext.Current.Session("CurrentUserAge"))
            End Get
            Set(ByVal value As Integer)
                HttpContext.Current.Session("CurrentUserAge") = value
            End Set
        End Property
    End Class
End Namespace
If you are using ViewState, you will declare these properties as part of your UserControl, for example. Because you are wrapping access to the data as you would a private field, you gain all the benefits of that, such as validation, initialization, default values etc. As you can see, the above example still relies on the developer coming up with a unique key for each object, which is the problem addressed by this article. By nature, all of your strongly typed properties will be unique, since they live in a unique namespace, classname, propertyname - anything else would give you a compiler error. So you can use this unique name as your key name. The following code shows how you can use the 'StackFrame' object to get a reference to the currectly executing method (which will get get_PropertyName, or set_PropertyName) and use (along with name of the declaring type) to generate a unique key for the data store:
Public Property Thing() As Integer
        Get
                Dim sfm As Reflection.MethodBase = New StackFrame().GetMethod()
                Return CType(HttpContext.Current.Session(sfm.DeclaringType.FullName & sfm.Name.Remove(0, 4)), Integer)
        End Get
        Set(ByVal value As Integer)
                Dim sfm As Reflection.MethodBase = New StackFrame().GetMethod()
                HttpContext.Current.Session(sfm.DeclaringType.FullName & sfm.Name.Remove(0, 4)) = value
        End Set
End Property
The reason I have used '.Remove(0, 4)' is to get rid of the 'get_' and 'set_' prefixes, so that the getter and setter function refer to the same key.