1

I have a SharePoint provider hosted app (hosted in Azure) that already works on 2 installations (all these environments are 100% separate environments).

Now that I am installing it on a 3rd environment I get

An error occurred while processing your request

The clientID and secretkey are correct. I checked the manifest in the actual app, connected with FTP to the Azure site to validate the settings in the web.config.

The ClientContext returns a "CanNotRedirect" because the httpMethod is POST

if (StringComparer.OrdinalIgnoreCase.Equals(httpContext.Request.HttpMethod, "POST"))
            {
                return RedirectionStatus.CanNotRedirect;
            }

If I ignore this error the next error is from the tokenhelper.cs. It's not finding the AppContext, AppContextToken, AccessToken or SPAppToken in the querystring or formrequest.

string[] paramNames = { "AppContext", "AppContextToken", "AccessToken", "SPAppToken" };
            foreach (string paramName in paramNames)
            {

                if (!string.IsNullOrEmpty(request.Form[paramName]))
                {
                    return request.Form[paramName];
                }
                if (!string.IsNullOrEmpty(request.QueryString[paramName]))
                {
                    return request.QueryString[paramName];
                }

Any ideas? I'm probably missing a configuration somewhere. All help is appreciated.

1
  • 1
    I am getting the same error. It used to work before but now it is not. I have a button on the default page of the remote app. When I click on the button and page does postback, Page_PreInit event kicks in and it throws the exception. Looks like for some reason user context is lost when postback happens. Commented Aug 20, 2014 at 9:21

1 Answer 1

1

Although I still don't know the exact cause of the error above. I did manage to get to work.

I uninstalled the app from all the site collections and from the SharePoint store. Generated a new clientid and secretkey, increased the version number of the app, updated the clientid in the publish wizard and reinstalled the app on the SharePoint server.

(The clientid and secretkey settings of the web project are set in the Azure configuration page of the web)

Not sure where it initially went wrong as all the (clientid, secretkey) settings were corretly set.

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.