Skip to content

WrappedAspNetCoreSession doesn't persist updated properties #698

Description

@rawling

Describe the bug

Compare the behaviour of the following between .NET Framework and .NET Core's AddWrappedAspNetCoreSession:

  • create a class with some simple value properties
  • via System.Web.HttpContext.Current.Session either
    • set a new instance of that class into session
    • pull an existing instance of that class out of session
  • update a property on the instance; do not explicitly write the instance back to System.Web.HttpContext.Current.Session
  • read the property in a subsequent call

In .NET Framework, the updated value is automatically persisted into session at the end of the first call.

In .NET Core via AddWrappedAspNetCoreSession, the updated value does not appear to be persisted into session at the end of the call unless you manually push the instance back into System.Web.HttpContext.Current.Session.

AspNetCoreSessionState does not seem to track what values have been added or retrieved and re-push them to the underlying _session in CommitAsync.

Further, if you retrieve the same value from session twice in one call, in Framework you get the same object, but in Core you get different objects. AspNetCoreSessionState does not seem to track what values have been pulled from the underlying _session and return the same instances.

To Reproduce

Similar Web API code running in Core and Framework.

Run via the caller:

Image

Further technical details

Please include the following if applicable:

ASP.NET Framework Application:

  • Technologies and versions used (i.e. MVC/WebForms/etc): WebApi. In-proc session provider. (Observed with SQL session provider too, but not tried with this repro.)
  • .NET Framework Version: 4.8
  • IIS Version: Express
  • Windows Version: 10

ASP.NET Core Application:

  • Targeted .NET version: 8 (observed in 10 too, but not tried with this repro)
  • .NET SDK version:
Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Triage 🔍Label added to new issues which need Triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions