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 GusoffCommented Apr 25, 2018 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.– MohammadCommented Apr 25, 2018 at 17:02
Add a comment
|
1 Answer
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.