Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Could you please help on the below thing.


I want to store the session data into dictionary object with key and get that data in to controller based on that key.

I have found the below code but not able to set the session data into controller.
C#
public static void SetValue(string dictionaryName, string key, string value)
       {
           if (!String.IsNullOrEmpty(key))
           {
               if (HttpContext.Current.Session[dictionaryName] != null)
               {
                   Dictionary<string, string> form = (Dictionary<string, string>)HttpContext.Current.Session[dictionaryName];
                   if (form.ContainsKey(key))
                   {
                       form[key] = value;
                   }
               }
           }
       }


Clear requirement :

First time i will search with account number that data should store into dictionary after that i will search with another account number that also store into same dictionary with different key finally i want to get the particular session based on key with in that dictionary.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900