How to store an object in a cookie?

后端 未结 10 1854
名媛妹妹
名媛妹妹 2020-12-15 08:49

While this is possible in C#: (User is a L2S class in this instance)

User user = // function to get user
Session[\"User\"] = user;

why this

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 09:14

    Try something like this?

    StringWriter outStream = new StringWriter();
    XmlSerializer s = new XmlSerializer(typeof(List>));
    s.Serialize(outStream, myObj);
    cookie.Value = outStream.ToString();
    

提交回复
热议问题