serializing session state in asp.net

限于喜欢 提交于 2019-12-01 06:25:24

As the exception says your Type

NopSolutions.NopCommerce.BusinessLogic.Categories.Category

is not serializable. I dont know the implementation of that type but you can try to decorate the type with the [Serializable] attribute.

If you cant do this you can simply write the id of the object to your session.

If you want your session stored in sql server, every object your write into your session needs to be serializable.

More Information

Adding the [Serializable] attribute (<Serializable()> in VB) automatically makes your class serializable. All the members in your class need to be serializable too. So suppose there are object references in your class. Then the classes which those objects belong to need to have the [Serializable] attribute too. Basic types are automatically serializable.

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