In my ASP.Net application, I'm storing a string collection in a Session variable. It was working fine but now I want to change session settings from in-proc to Out Proc. Now I'm having an issue that "Non-Serializable Object Stored in Session". How can I serialize the Sting Collection object before assigning it to a session variable? Please help.
Session["SelectedItems"] =customerGroupsList.SelectedItemsCollection;
I want to change above line of code.
如果它实际上只是一个字符串集合对象,那么您可以使用下面的代码序列化它并将其存储为String:
Session["SelectedItems"] = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(customerGroupsList.SelectedItemsCollection);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.