3

I have a provider hosted app in SharePoint Online. The problem I have is sometimes on postback the TokenHelper Class method GetContextTokenFromRequest is returning Context Token as NULL

  ContextToken = TokenHelper.GetContextTokenFromRequest(Page.Request);

1 Answer 1

1

I got the issue resolved by using view state for the Context Token property

 public string ContextToken
       {
            get
           {
            return ViewState["ContextToken"] != null ? Convert.ToString(ViewState["ContextToken"]) : String.Empty;
        }
        set 
        {
            if (value != null)
            {
                ViewState["ContextToken"] = value;
            }
        }
    }
1
  • 1
    Please let me know to which file you added this code (Provider Hosted App + Client Web Part), is it in the SharePointContext.cs ?
    – user42123
    Commented May 7, 2015 at 2:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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