serialization and deserialization of session data

ε祈祈猫儿з 提交于 2019-12-11 12:13:44

问题


I have stored session data in SQL server mode using asp.net.The data thus stored is serialized by asp.net.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


回答1:


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 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"];


来源:https://stackoverflow.com/questions/23527727/serialization-and-deserialization-of-session-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!