In this article, we will learn how to use our C# coding prowess to set up the session state in our ASP.NET Core and MVC Core Web applications.
Steps To Be Followed:
Step-1: New project:
Open Visual Studio and select File >> New Project.
The “New Project” window will pop up. Select .NET Core and select “ASP.NET Core Web Application”. Name our project and click “OK”.
A “New Project” window will pop up. Select Web Application and click “OK”, as shown below.
Also read: Steps to archive log files using NLog with ASP.NET Core
Once our project is ready, open Solution Explorer, right-click “dependencies”, and click “Manage NuGet Packages.”.
We need to install the stable version of “Microsoft.AspNetCore.Session” from the NuGet Package Manager. Then only we can access the session state in ASP.NET Core. Click on the “Install” button.
Now, double click “HomeControllers.cs”. The following is an example of a session sharing in ASP.NET Core.