I have developed a "web part" that has to be deployed on a Sharepoint server. I need the username of the user, who has logged in the sharepoint server within the web part.
How do I get that username?
Following worked for me:
SPWeb theSite = SPControl.GetContextWeb(Context);
SPUser theUser = theSite.CurrentUser;
string strUserName = theUser.LoginName;
and check this out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With