How can I get Current Logged in user of SharePoint Site in Provider Hosted App's code behind?
I tried this:
clientContext.Load(clientContext.Web, web => web.CurrentUser.LoginName); clientContext.ExecuteQuery(); var login_nm = clientContext.Web.CurrentUser.LoginName;userName = Request.LogonUserIdentity.Name.ToString();string u_nm = User.Identity.Name.ToString();
But what I am getting is current System User. Not the SharePoint user. Above all the Options are to get the Windows User Identity. Not for SharePoint site. What should I do to get SharePoint user in my App.
var c = new ClientContext(_hostWebUrl);where_hostWebUrlis my SP site. I am receiving the following error:ServerVersion = 'c.ServerVersion' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'– SearchForKnowledge Mar 26 '15 at 13:56parent._spPageContextInfo.userId. This way I can retrieve all the informations from the current session, into my App, accessed by my webpart . ;) – Alex Jun 08 '15 at 12:33