How to work with session state in ASP.Net Core

Take advantage of the session middleware component in ASP.Net Core to store and retrieve user data

ASP.Net Core is an open source, cross-platform, lean, extensible and modular framework for building high-performance web applications. Session state in ASP.Net Core enables you to store user data and persist the data across requests from the same client. You can take advantage of the necessary middleware (available as part of the (Microsoft.AspNetCore.Session package) to work with session state in ASP.Net Core.

Middleware components in ASP.Net Core are used to customize the handling of requests and responses, and inspect, route, or modify the request and response messages that flow through the pipeline. Usually, you have a chain of middleware components in the application pipeline in ASP.Net Core. This article presents a discussion on how we can work with session state in ASP.Net Core.

Create an ASP.Net Core MVC project

First off, let’s create an ASP.Net Core project in Visual Studio. Assuming Visual Studio 2017 or Visual Studio 2019 is installed in your system, follow the steps outlined below to create a new ASP.Net Core project in Visual Studio.

To continue reading this article register now