GridView Postback后出错Operation is not valid due to the current state of the object.
一、问题起因
最近项目中有一页面第一次search后正常,但是再次点击其它任何按钮都会报错,亦即postback后页面有问题,经检查是由于页面有一GridView且数据量极大,记录大概有上千条,这儿解释一下,本页面不允许分页要求所有的记录都要显示已方便使用,另你可能说为啥要用GridView啊?这也不是本文要讨论的问题。
经查,ASP.NET对postback是有限制的,确切地说是对postback后form上fields的集合大小的限制,默认大概1000,而我们这个页面仅仅Input, Select等就达到上千,所以才会造成页面出错即Operation is not valid due to the current state of the object.
二、问题解决
知道了原因,解决起来就容易了,如下在web.config中增加如下配置,把大小直接增加到5000
<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="5000" />
</appSettings>
三、后续说明
虽然表面上解决了此问题,但是此方案风险极大,微软之所以在2月推出此更新MS11-100 (http://technet.microsoft.com/en-us/security/bulletin/ms11-100.This security update is rated Critical for Microsoft .NET Framework 1.1 Service Pack 1, Microsoft .NET Framework 2.0 Service Pack 2, Microsoft .NET Framework 3.5 Service Pack 1, Microsoft .NET Framework 3.5.1, and Microsoft .NET Framework 4 on all supported editions of Microsoft Windows) 是因为要避免HTTP POST Hash Collision Dos即Hash碰撞的拒绝服务攻击,此漏洞影响盛广,Java, Python, PHP, Ruby等无一幸免,当然ASP.NET也在受害之列.
攻击原理: 该安全弱点利用了各语言的Hash算法的“非随机性”可以制造出N多的value不一样,但是key一样数据,然后让你的Hash表成为一张单向链表,而导致你的整个网站或是程序的运行性能以级数下降(可以很轻松地让你的CPU升到100%)
http://www.cs.rice.edu/~scrosby/hash/CrosbyWallach_UsenixSec2003.pdf
PHP攻击版本实现:http://blog.csdn.net/linvo/article/details/7169718 (仅供参考)
解决方法:
- Restrict the number of POST parameters (限制请求数 – MS11-100干的就是这个事)
- Restrict the size of the POST request (限制请求大小)
- Web Application Firewall
四、参考链接
http://forums.asp.net/t/1585040.aspx/1
GridView Postback后出错Operation is not valid due to the current state of the object.的更多相关文章
- 关于 error: Operation is not valid due to the current state of the object。
今天碰到一个特别的异常. Operation is not valid due to the current state of the object. at System.Web.HttpValueC ...
- “Operation is not valid due to the current state of the object.”
将Repeater单页显示的2000条数据一次性提交的时候出现这个错误: Operation is not valid due to the current state of the object. ...
- Error occurred in deployment step 'Add Solution': Operation is not valid due to the current state of the object.
Sharepoint 部署的时候出现一个错误 Error occurred in deployment step 'Add Solution': Operation is not valid due ...
- Operation is not valid due to the current state of the object.
今天遇到一个asp.net的草郁闷的问题,看下截图 狂晕啊,在google上狂搜了一下,好在已经有大侠也遇到过这个问题了,先看下别人的解决办法吧 Operation is not valid due ...
- kali kvm Requested operation is not valid: network 'default' is not active
安装时候参考的:http://www.ilanni.com/?p=6101 今天安装完kvm,满是幸福的装了个xp,重启后出现了一个错误 Requested operation is not vali ...
- Failed to decrypt protected XML node "DTS:Password" with error 0x8009000B "Key not valid for use in specified state.". You may not be authorized to access this information. This error occurs when t
Question SSIS包从A服务器搬迁到B服务器,运行报错 Description: Failed to decrypt protected XML node "DTS:Password ...
- vs问题解决:an operation is not legal in the current state
debug时弹出提示框:内容有:an operation is not legal in the current state 解决方案: Go to Tools > Options > D ...
- 初学React,setState后获取到的thisstate没变,还是初始state?
问题:(javascript)初学React,setState后获取到的thisstate没变,还是初始state?描述: getInitialState(){ return {data:[]}; } ...
- win7 安装JDK7和JDK8后,卸载JDK8后出错
这是本人学习Java过程中遇到的一些问题和解决方法,在此记录,方便本人查看,解决他人疑惑. 本人win7 x64旗舰版,同时安装了JDK7和JDK8,卸载了JDK8之后,cmd命令行输入:java - ...
随机推荐
- Swagger实现API文档功能
介绍: wagger也称为Open API,Swagger从API文档中手动完成工作,并提供一系列用于生成,可视化和维护API文档的解决方案.简单的说就是一款让你更好的书写API文档的框架. 我们为什 ...
- HDU4734——2013 ACM/ICPC Asia Regional Chengdu Online
今天做的比赛,和队友都有轻微被虐的赶脚. 诶,我做的题就是这个题目了. 题目描述就是对于一个十进制数数位上的每一位当做一个二进制位来求出这个数,这个定义为G(x). 题目给定你A和B,求在0-B范围内 ...
- 【ActiveMQ】- 发布/订阅模式
publish/subscribe 特点:A发送的消息可以被所有监听A的对象的接收,就好比学校的广播,所有的学生都可以收听校园广播信息. 消息生产者: package com.zhiwei.advan ...
- 【BZOJ4205】卡牌配对
Description 现在有一种卡牌游戏,每张卡牌上有三个属性值:A,B,C.把卡牌分为X,Y两类,分别有n1,n2张. 两张卡牌能够配对,当且仅当,存在至多一项属性值使得两张卡牌该项属性值互质,且 ...
- oracle 视图views
SELECT * FROM DBA_VIEWS WHERE VIEW_NAME='你的视图名'; SELECT * FROM USER_VIEWS WHERE VIEW_NAME='你的视图名'; S ...
- laravel 嵌套事务
什么是嵌套事务? 一般情况下我们都是一个 begin, 一个 commit 或 rollBack, 但是有可能我们有种场景需要 begin 然后在事务里面再开一个事务, 这就是嵌套事务. MySQL ...
- (一)C的编译,printf,规范化
(一)编译的具体过程: 以前一直觉得,C代码的具体实现过程就是把几个.c文件编译成.o文件,然后链接在一起就可以了.可是最近在看C Prime Plus查漏补缺基础知识的过程中发现,这里的链接其实链接 ...
- 前缀、中缀、后缀表达式以及简单计算器的C++实现
前缀表达式(波兰表达式).中缀表达式.后缀表达式(逆波兰表达式) 介绍 三种表达式都是四则运算的表达方式,用以四则运算表达式求值,即数学表达式的求解. 前缀表达式 前缀表达式是一种没有括号的算术表达式 ...
- Linux各种重要配置文件详解
1:网卡文件/etc/sysconfig/network-scripts/ifcfg-eth0 [root@Gin scripts]# cat /etc/sysconfig/network-scrip ...
- 用Anaconda安装本地python包
Anaconda确实带来了很多方便,但是之前也过多的依赖了conda自带的一键下载python包的功能.这不,这几天突然要用FastFM这个包,无奈conda里没有,于是只能从github下载下来,实 ...