首页 > 解决方案 > 在 ASP.net 网站上查看状态存在问题

问题描述

我刚刚将我的开发网站移到了一台新计算机上,并且大部分网页都可以正常工作。唯一不能工作的网页是有回发的网页。我知道代码工作正常,这就是为什么我认为它是由视图状态引起的。我不断收到此错误:

Value cannot be null.
Parameter name: inputString
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: inputString

这是引发错误的函数:

Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object

    'Dim vState As String = Me.Request.Form("__VSTATE")
    PageStatePersister.Load()
    Dim vState As String = PageStatePersister.ViewState.ToString
    If Not vState Is Nothing Then
        Dim bytes As Byte() = System.Convert.FromBase64String(vState)
        bytes = vioZip.Decompress(bytes)
        Dim format As New LosFormatter
        Return format.Deserialize(System.Convert.ToBase64String(bytes))
    Else
        Return Nothing
    End If

End Function

有谁知道它为什么给我这个错误?我找不到传递给它的可能为 null 的内容,但我知道代码本身不会传递任何 null 值。如果您需要更多信息,请告诉我。预先感谢您的回复。

标签: asp.netvb.netvisual-studio

解决方案


检查页面是否有EnableViewState="true"

并验证 web.config 中的站点范围设置 -

<pages enableViewState="true" enableViewStateMac="true" ... />

推荐阅读