SharePoint 2010: Fetching Current Username Programmatically

In order to get the current login user of the selected SharePoint website we can use the following code snippet.
public string getUserName()
        {
           return SPContext.Current.Web.CurrentUser.Name;
        }
Hope this helps Cheers

Comments

Popular posts from this blog

SharePoint 2010 Migration Woes: Importing and exporting lists template between different SP2010 Servers

Per-user throttling in SharePoint Online: a Recipe for getting blocked in SharePoint Online and way to Avoid it

Powershell: Filling up an Existing Excel Sheet with data from SQL Server