serializing session state in asp.net

后端 未结 2 647
-上瘾入骨i
-上瘾入骨i 2021-01-13 16:28

I\'m trying to store session state in SQL instead of InProc in our nopcommerce 1.9 install. When I make the requisite changes to the web.config I get this error:

相关标签:
2条回答
  • 2021-01-13 16:50

    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

    • Steps for Session InProc Mode to Session StateServer
    0 讨论(0)
  • 2021-01-13 17:07

    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.

    0 讨论(0)
提交回复
热议问题