We have developed a visual web part in asp.net. With using SPContext.Current.Web.CurrentUser.ID property, we control who is current user. In SharePoint, it is possible to change current user and this feature cause problem in web part. I am looking for a user change event in asp.net. Is there any event to control user change in asp.net?

  • If a person logs in as a different user, it'll trigger a full page request (several actually) so this isn't really a valid scenario. Every page load is a separate life cycle. – Derek Gusoff Apr 25 '18 at 13:55
  • I have a session for the current user. However, after a new user login, the information of the previous user display in web part unless the new user close browser and open it again. – mohammad Apr 25 '18 at 17:02

So the question is actually about keeping a session variable in sync when a user logs out and back in as a different user. Here's how I'd do it:

Store the user's username in a session variable. On each Page_Load, check it against the current logged in user. If they are different you know they've changed.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.