Monday, 15 February 2010

c# - cookie can have data other than string -


I have a purpose of a class meetinglist , I pass this object through the cookie

write cookies

  http cookie cookie = new HTTP cookie ("QuickJump"); Cookies ["meeting list"] = Child. Gate meeting list (person id, "open"). Toasting (); Response.Cookies.Add (Cookies);  

Reading Cookie

  http cookie cookie = request. Cookies ["quickjump cookie"]; Meetinglist ml = (meeting list) cookies ["meeting list"]; & Lt; - Error in this line  

I think you should do the serial and then your meetinglist Class

Serve your object in the cookie in some objects (for example, in JSON) and then deiserize it personally I use this newtonsoft.com/json library. Your code will look like

  Jason Convert Serialize Object (Your Metering List Obvious)  

and then

  meetinglist ml = (meetinglist) JsonConvert .DeserializeObject (Cookies ["MeetingList"])  


No comments:

Post a Comment