Printing out all the Variables in the Session.

vishalneeraj-24503
Posted by vishalneeraj-24503 under ASP.NET category on | Points: 40 | Views : 424
Suppose,we have 2 Session Keys as Name and Middle,so after looping through the Session Keys,it will print Values
Session["Name"] = "Vishal";
Session["Middle"] = "K";

VB.NET
Dim session_keys as string = string.Empty 
For Each session_keys In Session.Keys
Response.Write("Session Key Contain-> " + Session[session_key].ToString() + "</br>")
Next

C#
foreach (string session_key in Session.Keys)
{
Response.Write("Session Key Contain-> " + Session[session_key].ToString() + "</br>");
}

Output
Session Key Contain-> Vishal
Session Key Contain-> K

Comments or Responses

Login to post response