0

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!

Thanks.

1 Answer 1

2

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)) { } } 
1
  • I want on host web. The above code snippet I have used this also. But "spContext" is null. Commented Jul 19, 2017 at 14:33

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.