In-Proc sessions in Azure hosted web app getting cleared

moshan Kulathunga 1 Reputation point

In-Proc sessions in Azure-hosted web app getting cleared if continuously load the web app for about 5 to 10 mins. Once it starts happening it's likely to keep dropping sessions regularly for some time, then it starts to work again. Cannot find any app restarts or recycles during the time period. It seems like we might be hitting some sort of memory limit which kicks data out of the session cache, but cannot figure out what exactly causing to trigger this.

Azure App Services
Azure App Services
A feature of Azure App Service used to create and deploy scalable, mission-critical web apps.
4,560 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 11,441 Reputation points Microsoft Employee

    Thanks for asking question! InProc session mode indicates that session state is stored locally. This means that with InProc session state mode is stored as life objects in the App Domain of the Web application. This is why the session state is lost when Aspnet_wp.exe (or W3wp.exe, for applications that run on IIS) or the AppDomain restarts.

    To work around this problem, you can use StateServer or Configure SqlServer session state mode or Session state with Azure Redis cache. Also, as mentioned in the article, the best solution if you have to use session state is to use a cache provider, such as Session State Provider for Azure Cache.

    Further you may want to know that since you could scale up your web app to multiple instances, using In-Proc session mode is not a good practice for your to host your web app on Azure, which could not share session state between multiple instances of your web app.

    Also check this SO link here might helps.

    Let us know if further issue remains.