Session variable value is getting null in ASP.NET Core

For ASP.NET Core 2.1 and 2.2 In the ConfigureServices method of the Startup class, Set options.CheckConsentNeeded = context => false; as follows: services.Configure<CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => false; options.MinimumSameSitePolicy = SameSiteMode.None; }); Problem solved!

HttpContext.Current.Session is null when routing requests

Got it. Quite stupid, actually. It worked after I removed & added the SessionStateModule like so: <configuration> … <system.webServer> … <modules> <remove name=”Session” /> <add name=”Session” type=”System.Web.SessionState.SessionStateModule”/> … </modules> </system.webServer> </configuration> Simply adding it won’t work since “Session” should have already been defined in the machine.config. Now, I wonder if that is the usual thing …

Read more

Is there a best practice and recommended alternative to Session variables in MVC

You will never get unanimous opinion on anything in any large group of people. That’s just human nature. Part of that stems from the Dunning-Kruger Effect which states that the less someone knows about a subject, the more likely they are to over value their expertise in that subject. In other words, lots of people …

Read more