由于回发期间对象的当前状态错误,"操作无效"

Mut*_*mar 166 asp.net

我有一个运行良好的aspx页面,但突然我收到错误"由于对象的当前状态,操作无效".每当回发完成.

堆栈跟踪是:

在System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded()
在System.Web.HttpValueCollection.FillFromEncodedBytes(字节[]字节,编码方式进行编码)
在System.Web.HttpRequest.FillInFormCollection()

有人可以帮忙吗?

Dev*_*osh 279

有人在你的页面上发布了很多表单字段.最近的安全更新引入的新默认最大值为1000.

尝试在web.config的<appsettings>块中添加以下设置.在此块中,您将最大化MaxHttpCollection值,这将覆盖.net Framework设置的默认值.您可以根据表单需要相应地更改值

<appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="2001" />
 </appSettings>
Run Code Online (Sandbox Code Playgroud)

欲了解更多信息,请阅读这篇文章.有关Microsoft的安全修补程序的更多信息,您可以阅读此知识库文章


小智 40

我没有在gridview上应用分页,它扩展到600多条记录(带复选框,按钮等),2001的值不起作用.您可以增加该值,例如10000并进行测试.

<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="10000" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)


Dan*_*ich 16

对于ASP.NET 1.1,这仍然是由于有人发布了超过1000个表单字段,但必须在注册表而不是配置文件中更改该设置.它应该在注册表下添加为名为MaxHttpCollectionKeys的DWORD

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\1.1.4322.0
Run Code Online (Sandbox Code Playgroud)

适用于32位版本的Windows,以及

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\ASP.NET\1.1.4322.0
Run Code Online (Sandbox Code Playgroud)

适用于64位版本的Windows.


Man*_*jua 5

如果您的堆栈跟踪如下所示,那么您正在向服务器发送大量json对象

Operation is not valid due to the current state of the object. 
    at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32 depth)
    at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)
    at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)
    at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)
    at System.Web.Script.Serialization.JavaScriptSerializer.DeserializeObject(String input)
    at Failing.Page_Load(Object sender, EventArgs e) 
    at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
    at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
    at System.Web.UI.Control.OnLoad(EventArgs e)
    at System.Web.UI.Control.LoadRecursive()
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Run Code Online (Sandbox Code Playgroud)

为了解决问题,请使用以下键更新您的Web配置。如果您无法获取堆栈跟踪,请使用fiddler。如果仍然无法解决问题,请尝试将数字增加到10000左右

<configuration>
<appSettings>
<add key="aspnet:MaxJsonDeserializerMembers" value="1000" />
</appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)

有关更多详细信息,请阅读 Microsoft知识库文章