dotnet / dotnet/systemweb-adapters

Session Values are set to Null if you dont map them

Open
#503 2 comments 0 reactions 0 assignees View on GitHub
In-PR Needs: Triage :mag:
Dominant language
C#
Stars
384
Forks
76
Avg merge
2h 24m
Merged PRs (30d)
1

Description

### Describe the bug
When using ThrowOnUnknownSessionKey = false; with the options, it allows you to ignore keys that aren't yet mapped. However, those session values are nulled out rather than ignored. I'm not sure if this is intentional, but when converting large sites a page at a time, it would make sense if there was a way to completely ignore these keys that you don't need yet.

### To Reproduce

.NET Framework Side:

Configure to not throw on unknown keys and only register one key but then set 2 different keys in session:
![image](https://github.com/dotnet/systemweb-adapters/assets/127792741/582a5576-fcf0-4107-997c-aff64f302e32)
![image](https://github.com/dotnet/systemweb-adapters/assets/127792741/a28e1041-27d3-49d7-991a-daa7c3306cd1)

.NET 8 Side:

Configure to not throw on unknown keys and only register one key, view both keys and note that only 1 is set:
![image](https://github.com/dotnet/systemweb-adapters/assets/127792741/ea9f4d73-39a8-47fe-bcc0-3df6b366a9d7)
![image](https://github.com/dotnet/systemweb-adapters/assets/127792741/832def3c-3397-4c71-a1a6-b76459e3628a)

Load the .NET Framework side again and note test2 is now null:
![image](https://github.com/dotnet/systemweb-adapters/assets/127792741/7a9eeea5-fb20-4257-a940-592a94564a5b)

### Further technical details

Please include the following if applicable:

*ASP.NET Framework Application*:
- MVC
- .NET Framework Version: 4.7.2
- IIS Version:
- Windows Version: 11

*ASP.NET Core Application*:
- Targeted .NET version: .NET 8
- .NET SDK version:

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.