Search code examples
asp.net-core-mvcsession-cookies

I am trying to implement Sessions in controller of my ASP.NET Core MVC web application but it says "Session" doesnot exist in the current context


Error: CS0103: The name Session does not exist in the current context

I want to use sessions in my web application to check if user is logged in.

Here is the controller:

controller

I have also added the services in program.cs file but that doesn't seem to work either.

This is my program.cs:

program


Solution

  • I was trying to call HttpContent.Session but it was HttpContext.Session. Thank you for the support