会话数据的序列化和反序列化

编程入门 行业动态 更新时间:2024-10-27 11:26:37
本文介绍了会话数据的序列化和反序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经使用asp在SQL Server模式下存储了会话数据,因此存储的数据由asp序列化了,我正在使用一个反序列化数据并将其返回为对象类型的函数,现在我将如何检索数据? 我创建了一个可序列化的类,使用该类我将会话数据存储在表中。

I have stored session data in SQL server mode using asp.The data thus stored is serialized by asp.I am using a function to deserialize the data and return it in an object type.Now how will I retrieve the data? I had created a class,a serializable one,using which i am storing session data in the table.

任何与此相关的帮助都将非常有帮助。

Any help regarding this will be very helpful.Thanks

推荐答案

您不需要手动反序列化以ASP.NET会话状态存储的对象。如果您已将会话状态配置为:

You don't need to manually deserialize objects stored in ASP.NET session state. If you have session state configured like this:

<configuration> <system.web> <sessionState mode="SQLServer" sqlConnectionString="..." /> </system.web> </configuration>

ASP.NET将自动为您序列化和反序列化它。 因此,为了检索数据,只需从会话对象中读取它:

ASP.NET will automaticaly serialize and deserialize it for you. So in order to retrieve the data just read it from the session object:

Session["MyKey"] = new MyClass(); var myData = (MyClass)Session["MyKey"];

更多推荐

会话数据的序列化和反序列化

本文发布于:2023-10-22 23:54:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519110.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:序列化   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!