ASP.NET CORE 2.0 Hosting – How To Use Session Value Client Side Using JavaScript In ASP.NET?

In this article, I am going to explain how to use the value of the session variable at client-side using JavaScript in ASP.NET with an example. By using Session property, you can easily access the values of the session in JavaScript or jQuery based on our requirement. So, let’s take one example for demonstration.
We will write JavaScript code, shown as below.

Now, let’s understand how to integrate the created JavaScript in Aspx.

You can observe the above code. In this, we are trying to get ” UserName” session value client-side using Session property in JavaScript.

Now, open the code behind file and write the code like, as shown following.
C#

 VB.NET