HTTPSessionState  Class

CipherIS
CipherIS used Ask the Experts™
on
How do you place the Instance of the following class into the session of an ASP.NET application deployed to a server cluster with distributed sessions and used as a key for a Hashtable of other objects?  The modifications of the UserKey needs to meet the minimal requirements for an object which can be placed into this type of HttpSessionState

namespace myclass
{
    public class UserKey
    {
 
        private readonly String name;
        private readonly String userid;
 
        public UserKey(String name, String userid)
       {
           this.name = name;
           this.userid = userid;
        }
   
        public String GetName()
        {
            return name;
        }

        public String GetUserID()
        {
            return userid;
        }

    }
}
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Firstly in case of clustered, you need session mode as state server. Then you can use session as normal

UserKey ob = new UserKey ();
Session["key"] = ob;

Hope this will help you

Author

Commented:
u don't have to do anything like this -> http://www.dotnetjohn.com/articles.aspx?articleid=248?

Author

Commented:
How do you modify the class to use properties?
This simple class is immutable and therefore all instances of it will return the same value from GetHashCode(). Note that an object should return the same value from that throughout its lifetime. Its been a long time and I dont remember exactly but I think the default implementation of GetHashCode() does return different values when the object internals change. You can however override GetHashCode and provide your own implementation.
As far as i can remember, the hash rules are (but you can check in msdn)
- GetHashCode returns same value for entire lifetime of object
- Returned value should be as unique as possible to minimize collisions
- Objects that are identical in any sense of logical comparision (== operator), should return the same hash.
Secondly how a distributed hashtable behaves with objects that dont return the same hash values depends upon the implementation and also sometimes the topology. For example in partitioned case it could use the hash as an index into the server bucket to speed up operations. However it can also ignore the hash or calculate it differently and therefore behave differently.
You can however do some tests and/or read the docs to find out what.

Author

Commented:
was not resolved

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial