MS Teams Application HTTP Context Session Changed when Postback

Occasional Contributor

I have a MS Teams App that contains tab for opening SharePoint Add-ins (Provider-hosted) pages.

When using MS Teams Desktop and web, the session always changes when Postback and failed to get SharePoint Context.

Yannie_3-1642575341818.png

httpContext.Session.SessionID: jlsla5ggvdr2dbcpxivqxa5t

After clicking the button for Postback

Yannie_4-1642575392013.png

httpContext.Session.SessionID: nau5tyvs1rjbqrqvvqtx2cll

This only happens in using MS Teams Desktop and Web for some users.

 

Will there be a way stop refreshing the Http Context Session when Postback?

26 Replies
@Yannie - Could you please share more details on this issue? Also please share sample and repro steps, so that we can check it locally.

 We have a Provider-hosted SharePoint Add-in with several pages.

We put them on a MS Teams App as a tab by using App Studio.
The pages works well at first on MS Teams Desktop but recently users report that the issue persist while using Teams Desktop. 
After adding some debugging logs to the add-in, we found that the page session is null after postback and result in the application failed to get the SharePoint Context only when using MS Teams web and Desktop.

 

To replicate,

create a provider-hosted add-in and install to a SharePoint site

create a blank page with a button that will trigger postback in the add-in.

create the Teams app using App Studio and add the page as Tab.

Test and install the app

Open the tab and click the button using MS Teams web

 

@Meghana-MSFT

Thank you for providing the repro steps. We are checking this locally. We will get back to you.
@Yannie - Could you please confirm if your issue has resolved or still looking for any help?
STILL LOOKING FOR HELP AS CURRENTLY NOTHING IS SOLVED :)

@Yannie - Could you please share the reference docs or sample code that you are following (Including Provider-hosted SharePoint Add-in with several pages), so that we can investigate more on it.

As mentioned for thousand times, creating a blank page with a button (which also does not contain any functions) can also reproduce the issue.
@Yannie - We will check on it from our end and let you know.
@Yannie - Could you please share console logs when you get the error? Meanwhile we are also checking this at our end.
@ChetanSharma-msft, I have sent through Private message for all info I have on my side.
@Tannie - Thanks a lot for sharing the detailed repro steps.
We will try it from our end and let you know the updates.

@Yannie -  Could you please let us know what URL you have given here in this step? We tried with sharepoint site URLs but it gave us "Error occurred in deployment step 'Install SharePoint Add-in': Sideloading of apps is not enabled on this site. testSPAddIn 0" while running the code from Visual studio.

 

MeghanaMSFT_0-1644839883372.png

 

@Yannie - I tried creating a developer site as you suggested and created a project again. I am getting Microsoft.SharePoint.Client.ServerUnauthorizedAccessException after running the project. I apologize for asking many times. Is it possible for you to share developer site url and demo tenant details so that it would be easier for us to check this issue. 

@Yannie - We were able to repro this but we see that, this issue is happening in browser as well. This does not seem like an issue on Microsoft Teams side. Could you please confirm it?

 

MeghanaMSFT_0-1645118717107.pngMeghanaMSFT_1-1645118726434.jpeg

 

@Meghana-MSFT, please note that the issue ONLY happens in Teams :) Mine looks fine in browser.

We have added an on click event to the button and now its working on web but does not work in MS Teams. We are checking this with the engineering team.

@Meghana-MSFT Please let me know if there are any updates, thank you