SiteContext.CurrentUser vs MembershipContext.AuthenticatedUser

Matthew Lee asked on November 8, 2015 23:54


I have a question request to these two classes

  1. SiteContext.CurrentUser
  2. MembershipContext.AuthenticatedUser

Basically, I added a LogOnForm webpart (Out of the box in Kentico) in a page and logged in through this page. I found that the SuteContext.CurrentUser return null and MembershipContext.AuthenticatedUser return me a correct user. I was wondering do I use MembershipContext.AuthenticatedUser all the time or under what situation I would useSiteContext.CurrentUser?

Should I add a line to set the SiteContext.CurrentUser = MembershipContext.AuthenticatedUser in the webpart?

Recent Answers

David te Kloese answered on November 9, 2015 01:45


You should use MembershipContext.AuthenticatedUser!


It is available when the request contains parameters "userid", "username" or "userguid" with valid value of the user.

So MembershipContext.AuthenticatedUser is an actual logged-on user, where as the other can be manipulated by url parameters.



4 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.