Asp.net状态服务器无法序列化会话状态

时间:2014-01-28 06:46:12

标签: asp.net stateserver

我正在使用StateServer会话,使所有对象[Serializable]仍然出错。这是什么问题?

无法序列化会话状态。在' StateServer'和' SQLServer'在模式下,ASP.NET将序列化会话状态对象,因此不允许使用不可序列化的对象或MarshalByRef对象。如果自定义会话状态存储在'自定义'中进行类似的序列化,则适用相同的限制。模式。

这里是代码......在Response.Redirect上获取错误(" common / TicklerDisplay

Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
    Try
        SetOffset()
        strUserName = txtEmaillAdd.Text.Trim
        strPassword = txtPassword.Text.Trim



        Dim strSubscriptionLogin() As String = CCommon.ToString(ConfigurationManager.AppSettings("SubscriptionManagement")).Split("/")
        If strSubscriptionLogin.Length = 2 Then
            If strSubscriptionLogin(0) = strUserName And strSubscriptionLogin(1) = strPassword Then
                Session("DomainID") = 1
                Session("UserContactID") = 1
                Session("PagingRows") = 20
                Session("DateFormat") = "DD/MONTH/YYYY"

                Response.Redirect("Service/frmSerNav.htm", False)
                Exit Sub

            End If
        End If

        If sb_GetDomainUser() = False Then
            Session.Abandon()
            Exit Sub
        End If
    Catch ex As Exception
        ExceptionModule.ExceptionPublish(ex, Session("DomainID"), Session("UserContactID"), Request)
        Response.Write(ex)
        Session.Abandon()
        Exit Sub
    End Try

    If GetQueryStringVal("From") = "Help" Then
        Dim HelpURL As String = ConfigurationManager.AppSettings("HelpURL")

        HelpURL = HelpURL & "?a=" & objCommon.Encrypt(Session("AccessID")) & "&pageurl=" & CCommon.ToString(GetQueryStringVal("pageurl"))
        Response.Redirect(HelpURL)
        Exit Sub
    Else
        Response.Redirect("common/TicklerDisplay.aspx?ClientMachineUTCTimeOffset=" & txtOffset.Text.Trim)
        'HttpContext.Current.ApplicationInstance.CompleteRequest()
    End If
    'Response.Redirect("include/frmMenu.aspx")
End Sub

1 个答案:

答案 0 :(得分:0)

检查堆栈跟踪引发错误的位置。它应该告诉你它无法序列化的对象。根据上面的评论,并非所有对象都可以序列化。

请参阅:How can I find which object in ASP.NET can't be serialized?