What is the recommended method for persistently storing variable variables in ASP.NET when using a custom membership provider?

I have an ASP.NET application that uses a custom MemberhipProvider to allow users to log in and access certain functions. MemberhipProvider uses ASP.NET built-in forms authentication to set cookies and track who the user is.

Now that I have registered a user, what's the best way to store user information for my session? I used to just use session variables, i.e. Session["ReputationLevel"] = "4230";(my application does not actually have a variable reputation level, this is just an example). Is this the best way when using MembershipProvider? Would it be better to somehow collect this information in the provider itself or in the user implementation of MembershipUser? If I keep everything in the session, I suppose I will have to drop the session when MemberhipProvider indicates that the user is logged out ...?

Sorry if this question is unclear. I have mainly been developing ColdFusion over the past few years, and I'm still new to some of these ASP.NET technologies. I thought the MembershipProvider functionality would take care of everything I needed, but now I can see that there are still some holes in my implementation (in this case, where to store additional data).

This question seems similar , but it seems to be not quite what I am asking.

+3
source share
2 answers

If you want to save information outside the session, it is best to save it to the user in your database. There are several ways to do this:

  • , SQL - , db .
  • MemberShipUser . ...
  • ASP.NET Profiles, , . , .
+2

, , , . , . , , . , :

static string GetUserReputation()
{
   return Session["Reputation"].ToString();
}

GetUserReputation

+1

All Articles