Last post Feb 04, 2019 12:36 AM by bruce (sqlwork.com)
Feb 03, 2019 03:53 PM|flynch55|LINK
How do I detect that a session is new?
I have kludged something together using cookies but there has to be a better way. Under ASP.NET 4.x I was able to ask the HttpContext.IsSessionNew (or something similar). How does one do this in Core 2.1?
Feb 04, 2019 12:36 AM|bruce (sqlwork.com)|LINK
asp.net core uses a different approach to session.
1) unlike classic asp.net it does not lock a session object.
2) access to a session object is async
3) session is not accessed until the first access of a session object in the request
4) session will not be saved unless a session object is created / replaced in the request
to implement what you want, just create an object and store in session. if its not there, its a new session.