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?
Hey all, i got the answer for my question Hope this will work for you all... First add a reference to the MicrosoftSharepoint.dll file in your web part. then write using Microsoft.SharePoint;
string username;
string sspURL = "URL where Sharepoint is deployed";
SPSite site = new SPSite(sspURL);
SPWeb web = site.OpenWeb();
SPUser user = web.CurrentUser;
username = user.LoginName;
site.AllowUnsafeUpdates = true;
Yours, Jigar <3