C# Developers' Journal (original) (raw)

4:30p

Attach class to a Session in ASP.NET Say, I have two classes:

Buyer
Seller

Say, I also have a class

User

which can be either Buyer or Seller, or both, or anonymous. In fact, I want User to represent the current session, and have the following member variables:
(i wrote self-explanatory members' names)

User.the_page_Im_on_right_now

User.the_page_I_wanned_to_visit_but_got_redirected_to_login

User.class_seller_or_null_if_im_not_seller

User.class_buyer_or_null_if_im_not_buyer

As you see, the User class only makes sense to keep during a session. How can I connect this kind of class with a session, so that the object of the User class gets created when a user goes to the website, it disappears when user leaves; and it stays available as the user goes from page to page?

Maybe there are built in functions for this whole thing, and I'm inventing a wheel?

(I'm using ASP.NET 2.0 with C#)