How to store account-specific information in ASP.NET MVC 2

Posted by PR_ on Stack Overflow See other posts from Stack Overflow or by PR_
Published on 2010-05-31T08:46:46Z Indexed on 2010/05/31 8:52 UTC
Read the original article Hit count: 282

I have an ASP.NET MVC 2 web application. There are two tables like "FIRST_KIND_OF_USERS" and "SECOND_KIND_OF_USERS". Both are mapped to the default aspnet_users table via UserId column. Each of them has it's own integer primary key column like "FirstKindOfUsersId".

When a user is trying to add some data to the database, for instance, "Create a new Task" I would like to add a new row in Tasks table with "FirstKindOfUsersId" value.

Where should I store or get this value?

At the moment I have these possible solutions:

  1. Get "FirstKindOfUsersId" value by User.Identity.Name each time;
  2. Use SESSION[] for storing these values (Where and when should I save these ones?)
  3. Use FormsAuthenticationTicket and create own custom IIdentity class. (http://stackoverflow.com/questions/1064271/asp-net-mvc-set-custom-iidentity-or-iprincipal)

Which approach is better? And if I pick the 3rd one, how to save the necessary data property and at which stage?

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc-2