App forces user back to login when apppool recycles

208 Views Asked by At

We have a private .net app that runs on IIS windows server 2016. We are using the sessionstate service Forms authentication with cookies

When we recycle the apppool then any users are forced back to the login page. This is not the behaviour expected or wanted.

If we set up the same code on windows 10 we don't have that problem. We are struggling to replicate this in any other environment.

Is there some setting in IIS or else where that would affect this functionality ?

2

There are 2 best solutions below

0
Bruce Zhang On

When I check the document, a possible is that identity of application pool will cause this issue. If identity of applocation pool is ApplicationPoolIdentity, nothing will happen. Only using custom account may happen. I think this is not accurate, but you can check the identity.

In IIS, you can change session state mode to keep user login even when application pool recycles.

Generally, IIS stores session state values and variables in memory on the local Web server. So you can use SQL Server Mode. SQL Server mode stores session state in a SQL Server database. Using this mode ensures that session state is preserved if the Web application is restarted, including application pool recycles, and also makes session state available to multiple Web servers in a Web farm.

<configuration>
  <system.web>
    <sessionState mode="SQLServer"
       sqlConnectionString="Integrated Security=SSPI;data 
       source=SampleSqlServer;" />
 </system.web>
</configuration>
0
user10069751 On

Thanks for pointing us in the right direction by mentioning the user. The fix was to change the property "Load user profile" to True, the default value.