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

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

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

SPFx: Develop using SharePoint Framework without Installing all the dependecies.