一、问题起因

  最近项目中有一页面第一次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%

Hash散列攻击: http://stackoverflow.com/questions/8669946/application-vulnerability-due-to-non-random-hash-functions

    http://www.cs.rice.edu/~scrosby/hash/CrosbyWallach_UsenixSec2003.pdf

PHP攻击版本实现:http://blog.csdn.net/linvo/article/details/7169718 (仅供参考)

解决方法:

  1. Restrict the number of POST parameters (限制请求数 – MS11-100干的就是这个事)
  2. Restrict the size of the POST request (限制请求大小)
  3. Web Application Firewall

  

四、参考链接

  http://forums.asp.net/t/1585040.aspx/1

  http://stackoverflow.com/questions/8832470/operation-is-not-valid-due-to-the-current-state-of-the-object-error-during-pos

GridView Postback后出错Operation is not valid due to the current state of the object.的更多相关文章

  1. 关于 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 ...

  2. “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. ...

  3. 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 ...

  4. Operation is not valid due to the current state of the object.

    今天遇到一个asp.net的草郁闷的问题,看下截图 狂晕啊,在google上狂搜了一下,好在已经有大侠也遇到过这个问题了,先看下别人的解决办法吧 Operation is not valid due ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 初学React,setState后获取到的thisstate没变,还是初始state?

    问题:(javascript)初学React,setState后获取到的thisstate没变,还是初始state?描述: getInitialState(){ return {data:[]}; } ...

  9. win7 安装JDK7和JDK8后,卸载JDK8后出错

    这是本人学习Java过程中遇到的一些问题和解决方法,在此记录,方便本人查看,解决他人疑惑. 本人win7 x64旗舰版,同时安装了JDK7和JDK8,卸载了JDK8之后,cmd命令行输入:java - ...

随机推荐

  1. python杂谈:Python中\r的用法示例

    \r 默认表示将输出的内容返回到第一个指针,这样的话,后面的内容会覆盖前面的内容 import sys import time def view_bar(num,total): rate = floa ...

  2. Idea(二) 解决IDEA卡顿问题及相关基本配置

    一.IDEA太卡顿,设置使用IDEA的内存 在IDEA的安装目录下的bin目录下: 打开设置: 将idea.exe.vmoptions文件内由-server-Xms128m-Xmx512m-XX:Ma ...

  3. 使用userData兼容IE6-10,chrome,FF 及360等浏览器的本地存储

    开发过程中涉及本地存储的使用,IE很多版本都不支持localStorage,没办法,就得兼容使用userData了.废话不说了,看代码: (function(window){var LS;(funct ...

  4. 【大数据】MapTask并行度和切片机制

    一. MapTask并行度决定机制 maptask的并行度决定map阶段的任务处理并发度,进而影响到整个job的处理速度 那么,mapTask并行实例是否越多越好呢?其并行度又是如何决定呢? 1.1 ...

  5. 一些常用的基础Linux操作指令

    复习的时候顺便分享我学的知识,虽不是什么牛的技术分享,只是一些基础,基础打好了技术慢慢就提高了!一起加油一起共勉! 具体的vi和vim命令集太多了,以后的随笔我也会分享出来,没必要全记住,记住常用的就 ...

  6. MySQL 测试工具(基准测试、压力测试)

    1.sysbench sysbench是跨平台的基准测试工具,支持多线程,支持多种数据库: 主要包括以下几种测试: cpu性能 磁盘io性能 调度程序性能 内存分配及传输速度 POSIX线程性能 数据 ...

  7. MT【120】保三角函数

    评:1.这里处理第三个函数时用到$ab-a-b=(a-1)(b-1)-1$是处理$ab,a+b$之间加减的常见变形. 2.第二个函数$g(x)=sinx,x\in(0,\frac{5\pi}{6})$ ...

  8. 学习Spring Boot:(二)启动原理

    前言 主要了解前面的程序入口 @@SpringBootApplication 这个注解的结构. 正文 参考<SpringBoot揭秘 快速构建微服务体系>第三章的学习,总结下. Sprin ...

  9. Java的内存结构

    Java中的内存结构 运行时数据区域的划分: 程序计数器(PC寄存器) 程序计数器(Program Counter Register)是一块较小的内存空间,可以看做是当前线程所执行的字节码的行号指示器 ...

  10. bzoj 2839 : 集合计数 容斥原理

    因为要在n个里面选k个,所以我们先枚举选的是哪$k$个,方案数为$C_{n}^k$ 确定选哪k个之后就需要算出集合交集正为好这$k$个的方案数,考虑用容斥原理. 我们还剩下$n-k$个元素,交集至少为 ...