SharePoint App "SPAppWebUrl" query string is missing after using "SharePointContextProvider.CheckRedirectionStatus"

Eleanor: 20 May 2022

When using a direct link(bookmark) to a page in my provided app the "SPAppWebUrl" query string is missing and the SPContext.CreateAppOnlyClientContextForSPAppWeb() is null.

This happens after the current user has been authenticated in the "SharePointContextProvider.CheckRedirectionStatus" method:

 protected void Page_PreInit(object sender, EventArgs e)
        switch (SharePointContextProvider.CheckRedirectionStatus(Context, out redirectUrl))
            case RedirectionStatus.Ok:
            case RedirectionStatus.ShouldRedirect:
                Response.Redirect(redirectUrl.AbsoluteUri, endResponse: true);
            case RedirectionStatus.CanNotRedirect:
                Response.Write("An error occurred while processing your request.");

The original direct link to page has the query parameters "SPHostUrl" and "SPAppWebUrl" and is working fine if the user already have been authenticated.

The "SPAppWebUrl" parameter is empty and "AppOnlyAccessTokenForSPAppWeb" is null after the current user has been authenticated running when the "RedirectionStatus.ShouldRedirect": enter image description here

If the current user already has been authenticated in SP before accessing the page (RedirectionStatus.Ok), everything is working fine: enter image description here

In the AppManifest.xml i am using query strings: enter image description here

The {StandarsTokens} have the "SPAppWebUrl" query string.

I really appreciate if someone can help me!

Aiden: 20 May 2022

My first guess is, have you specified redirect url while registering your app in appregnew.aspx page?

For more info check this link (

Basically what is happening is when you use bookmark to navigate to your app, the context token has expired. So you need to redirect to sharepoint site first to re-authenticate.

Hope this helps.