I am created 1 Provider Hosted App in SharePoint 2013. I am not able to get Client Context.

I have tried different options for getting the Client context. Almost all option that is available to get client context but no success.

FYI :- I host this app on my local iis, and without https

Please help me in this!



It depends where you need the ClientContext and if you need to access resources in host web or app web.

Getting ClientContext on page

protected void Page_Load(object sender, EventArgs e)
    SharePointContext spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
    using (ClientContext cc = spContext.CreateUserClientContextForSPHost())

Getting ClientContext in remote event receiver

public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
    using (ClientContext cc = TokenHelper.CreateAppEventClientContext(properties))
  • I want on host web. The above code snippet I have used this also. But "spContext" is null. – Krunal Patel Jul 19 '17 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.