What should I do with HttpContext.Current.Session

I am just beginning to look at porting our Asp.net web site to mobile. When I did a code portability analysis, all my References and usage of Http sessions are not portable. Makes complete sense, but my question is, what do I do with them? How do I maintain state in the mobile world?



  • PeterDavisPeterDavis USMember ✭✭✭

    State information is just data. You can store it in a database. You can store it in variables. I'm not entirely sure what you're asking. It probably depends on what the specific data is and what the requirements are for it. How long do you need to hold onto it? If you just need it for a the app run, then just create objects to hold your data. If you need it to persist across multiple runs, use a database.

  • iszoleaiszolea AUMember

    Hi Peter,

    Thanks for your feedback. One scenario is where we have a base class for all our business objects. The constructor for the class uses session properties which are populated during user login. Eg, username, office number, workstation ID, name, rank, regiment etc. each business object has these properties persisted for each record in the database.

    So, I imagine I need to populate some type of context object in each mobile systems application layer and pass that into the object constructor.

    Or, is there a better way...?

    I am a session cripple and can't really survive without it even though I know it is bad for me...


  • PeterDavisPeterDavis USMember ✭✭✭

    Well, the Sessions is really little more than a fancy dictionary, so you could just create static Session object kind of like this:

    public static class Session
        static Session()
            Data = new Dictionary<string, object>();
        public Dictionary<string, object> Data;

    Then it's globally accessible and you should be able to use it pretty similarly to how you use session.

Sign In or Register to comment.