Home > Enterprise >  Localhost Asp.Net application losing session values on postback
Localhost Asp.Net application losing session values on postback

Time:08-24

My localhost application is losing all session values after a postback from the application that handles the authentication for us.
When I deploy the application on my development server that has the same domain as the authentication application, the session values are kept.
I've checked all the settings related for the pool and the Session State on IIS and they're the same on my machine and the server.

CodePudding user response:

My problem was related to the SameSite Cookie changes that happened in 2019.
Adding this to the <system.web> section of the web.config solved the problem:

<httpCookies sameSite="None" requireSSL="true"/>
<authentication>
  <forms cookieSameSite="None" requireSSL="true" />
</authentication>
<sessionState cookieSameSite="None"/>

More information on SameSite Cookies here:
https://docs.microsoft.com/en-us/aspnet/samesite/system-web-samesite

  • Related