dotnet/aspnetcore

LoadAsync on Session - when _isNewSessionKey is true

Open

#20.898 geöffnet am 16. Apr. 2020

Auf GitHub ansehen
 (10 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (10.653 Forks)batch import
Perfaffected-fewarea-middlewarebreaking-changeenhancementhelp wantedseverity-nice-to-have

Repository-Metriken

Stars
 (37.933 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 16T 9h) (258 gemergte PRs in 30 T)

Beschreibung

https://github.com/dotnet/aspnetcore/blob/8b000d961cd3ccfcc8090fb8368fd6598bace978/src/Middleware/Session/src/DistributedSession.cs

Should Load/LoadAsync be a no-op when _isNewSessionKey is true. Taking the advice to call LoadAsync prior to accessing the session with get/trygetvalue/set I would of thought we'd guard against unnecsssary chitchat to the cache if we know the session is new?

I though about doing Request.Cookies["sesscoookie"] != null then await LoadAsync but then doing Get/Set/Id/IsAvailable will simply call load anyway if not _loaded isnt marked.

Contributor Guide