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

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;
            }
        }
    }
| improve this answer | |
  • Please let me know to which file you added this code (Provider Hosted App + Client Web Part), is it in the SharePointContext.cs ? – user42123 May 7 '15 at 2:54

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.