As per the docs, I have added recommended code in Startup.cs
In the OnGet handlers of razor pages, I noticed that HttpContext.Session.Id keeps changing between the page requests. As a result, I am not able to maintain state on the server.
Has anyone encountered this issue? I am using ASP.NET core 2.1.1
Resolution found in this post "ASP.NET core 2.1 session"