Recently i faced a problem in event handler to do some operation for the current logged in user,but inside event handler SPContext object is null. So after some probe we found a way to get the current user object .
For this we need to get the HttpContext object inside the constructor of the event handler
Here is the sample code :
———————————————–
HttpContext current;
///
/// Constructor to get the current logged in user details
///
public ListEventHandler()
{
current = HttpContext.Current;
}
————————————————-
Now to get the login name of the current user use this code:
string currentUserLoginName = current.User.Identity.Name;
————————————–
So your job is done
Enjoy!!!
No comments:
Post a Comment