CreateUserClientContextForSPHost() public method

Creates a user ClientContext for the SharePoint host.
public CreateUserClientContextForSPHost ( ) : ClientContext
return ClientContext
        protected void Page_Load(object sender, EventArgs e)
        {
            spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

            using (var clientContext = spContext.CreateUserClientContextForSPHost())
            {
                clientContext.Load(clientContext.Web, web => web.Title);
                clientContext.ExecuteQuery();
                Response.Write(clientContext.Web.Title);
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

            using (var clientContext = spContext.CreateUserClientContextForSPHost())
            {
                clientContext.Load(clientContext.Web, web => web.Title);
                clientContext.ExecuteQuery();
                Response.Write(clientContext.Web.Title);
            }
        }