Home > MVC > How to display session variable into View in ASP.NET Core



How to display session variable into View in ASP.NET Core

In this article, we have described how to display session variable into View in ASP.NET Core with an example and sample code.


In this article, we have described how to display session variable into View in ASP.NET Core with an example and sample code. The Session state server-side app code. session state supports several storage options for session variables. the session is a state that is used to store and retrieve the values of a user. primarily used to manage the user login but it is used for user session management as well.

 

Required Namespaces

you will need to use the following namespaces.

 

HTML

In the html we have taken Textbox for username and password . When the click on login button save the username in the session .

 

Model

 

Controller

In the Controller we are storing the Username in the session.

 

UserView.cshtml

We are get the session from user session variable.

 

Startup

We have provided Startup file below.

 

Screenshot

How to display session variable into View in ASP.NET Core



Note: All contents are copyright of their authors.



Comments



Leave a Reply

Comment:*
Email ID:*


Name:*