UserState Component for Forms Auth

If you're using Forms Authentication in your ASP.NET Web Applications, you can use the UserState object to store user related content as part of the Forms Authentication ticket.

The idea of this control is to store a few static user values when the user first authenticates, and then carry them as part of the forms authentication ticket associated with the user for easy retrieval. It allows you to keep a few simple user items like name, user id, or email address that might be used in the UI, without having to look up the user again in a database or other user store. You can add custom properties to your own UserState subclass and those values will be persisted. Keep these values to a minimum to avoid bloating the size of the Forms Auth ticket cookie.

By caching these and any other custom values in the Forms Auth ticket you can avoid repeated trips to the database just to retrieve a user record or having to rely on SessionState for simple user tracking.

Please note that this only works if users are logged in - if you need to track user data on anonymous users you still need another mechanism like Cookies or SessionState to track user data.

© West Wind Technologies, 1996-2016 • Updated: 12/19/15
Comment or report problem with topic