Unable to serialize the session state

后端 未结 8 1687
一生所求
一生所求 2020-12-01 23:06

When putting my application on a web server and trying to \'log in\' I get the following error:

Server Error in \'/\' Application.
Unable to serialize the se         


        
相关标签:
8条回答
  • 2020-12-01 23:49

    Can we see the "Gebruiker" class? There error seems straightforward enough. Gebruiker is not attributed as being Serializable therefore it can't be placed in Session for StateServer and SQLServer modes.

    EDIT:

    After looking at the code you linked in, yes, it's probably because the class isn't serializable. The LINQ generated class should be a partial class so you can implement your own partial class that marks it as Serializable and the sessionstate requirements will be met then.

    [Serializable()]
    public partial class Gebruiker { //Lots of stuff }
    

    EDIT 2:

    Thomas, your Gebruiker class probably has a definition that looks like this right now (or something similar)

    namespace XYZ
    {
       public partial class Gebruiker
    }
    

    Just create another class file that has the same namespace and define the class with the Serializable attribute

    namespace XYZ
    {
      [Serializable()]
      public partial class Gebruiker{}
    }
    

    That's all you should need in this file. This way, the serializable attribute won't be overwritten when the LINQ generated Gebruiker class gets created.

    0 讨论(0)
  • 2020-12-01 23:50

    Some times you have to check below property in your web.config

    <sessionState mode="InProc" ........../>
    
    0 讨论(0)
  • 2020-12-01 23:51

    Based on the code you posted: that class is generated as partial, so all you need to do is add another partial definition like this (in the same namespace as the generated partial class, of course):

    [Serializable]
    public partial class Gebruiker {}
    
    0 讨论(0)
  • 2020-12-01 23:55

    If you come across this error message on SharePoint 2013, don't forget to run the following PowerShell cmdlet:

    Enable-SPSessionStateService -DefaultProvision
    

    This error message is new in SP2013; see this question for SP2010: Session state can only be used when enableSessionState is set to true either in a configuration

    0 讨论(0)
  • 2020-12-01 23:56

    In my case, I was trying to serialize the non-serialized object that is HttpResponse. So if provided solutions won't work, you can go through solution of unable to serialize session state article.

    Hope it help others!

    0 讨论(0)
  • 2020-12-01 23:59

    If SessionState mode = "SQLServer" then you have to use [Serializable()] public partial class Gebruiker .

    otherwise you have to change your SessionState mode to "Inproc" Example :

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