1. The default class
Ina SharePoint provided-hosted project, as the project is built, the defaultSharePointContext.cs will be created in the 'Web Project' of the App project
And in this class, there is a function named 'GetSharePointContext', the default function is as follows:
public SharePointContext GetSharePointContext(HttpContext httpContext)
{
return GetSharePointContext(new HttpContextWrapper(httpContext));
}
Usually,we will store the clientContext in the session to re-use it. However,sometimes, the session will be expired.
2. The function in use
After a long research, we decide to use the following method to get the ClientContext:
3. How to get the parameter 'SPHostUrl'
3.1 At the front-end
3.2 At the back-end