1 year ago

#365484

test-img

ymnj10

Session variable lost randomly in .Net Core MVC app

We found that a session variable is randomly missing in our .Net Core 3.1 MVC application. The behavior is that we serialized and stored a json string with a key in the session. For most parts, we can retrieve the value with no problem. However, we found that the same item is missing sometimes (particularly last stored entry). No error, just no matching item found in the session. The session has not expired when it's missing and our code doesn't contain removal of the session item. AppPool is not recycled either.

Below are the logs that we captured during the error time. Strange enough that the session is loaded with Count 6 and suddenly become Count 5. Does anyone have a clue how it could happen? Is it a problem within .Net Core?

2022-03-31 17:37:00,724 DEBUG Microsoft.AspNetCore.DistributedSession.LogMessage [0] - MESSAGE: Session loaded: Key:22ceaeb2-802e-fd67-215c-3a83ffcda2c8, Id:af78b774-c675-db5b-aaa8-47d28d8bd13, Count:6

2022-03-31 17:37:06,138 DEBUG Microsoft.AspNetCore.DistributedSession.LogMessage [0] - MESSAGE: Session loaded: Key:22ceaeb2-802e-fd67-215c-3a83ffcda2c8, Id:af78b774-c675-db5b-aaa8-47d28d8bd13, Count:5

Thanks,

.net

asp.net-core

session-variables

0 Answers

Your Answer

Accepted video resources