只能在执行 Render() 的过程中调用 RegisterForEventValidation;
来源:互联网 发布:caffe github issue499 编辑:程序博客网 时间:2024/06/01 13:52
在调试程序中遇到如下问题:
在实现"将GridView中的数据导出到Excel中"的时候出现了如下错误:
用户代码未处理 InvalidOperationException
只能在执行 Render() 的过程中调用 RegisterForEventValidation;
分析:EnableEventValidation属性是 .NET Framework 2.0 中是新增的属性,默认的情况下该属性的值为true;通过这个新增的功能ASP.NET会检查 POST方法中的所带的参数,如果认为不合法,就会抛出异常。这个设计的目的是为了防止恶意用户利用post 方法发送一些恶意数据,但是有时也会出现类似上面的错误。
解决办法:只要禁止这个功能,问题就能得到解决。可以通过以下两种途径解决:
1、在Web.Config文件中:在<system.web></system.web>标记中添加如下代码:
<system.web>
<pages enableEventValidation="false"> </pages>
</system.web>
2、在具体的.aspx页面的源代码中修改代码,如下:
<%@ Page Language="C#" EnableEventValidation="false" AutoEventWireup="true" CodeFile="GridView_Export_Excel.aspx.cs" Inherits="GridView_Export_Excel" %>
在实现"将GridView中的数据导出到Excel中"的时候出现了如下错误:
用户代码未处理 InvalidOperationException
只能在执行 Render() 的过程中调用 RegisterForEventValidation;
分析:EnableEventValidation属性是 .NET Framework 2.0 中是新增的属性,默认的情况下该属性的值为true;通过这个新增的功能ASP.NET会检查 POST方法中的所带的参数,如果认为不合法,就会抛出异常。这个设计的目的是为了防止恶意用户利用post 方法发送一些恶意数据,但是有时也会出现类似上面的错误。
解决办法:只要禁止这个功能,问题就能得到解决。可以通过以下两种途径解决:
1、在Web.Config文件中:在<system.web></system.web>标记中添加如下代码:
<system.web>
<pages enableEventValidation="false"> </pages>
</system.web>
2、在具体的.aspx页面的源代码中修改代码,如下:
<%@ Page Language="C#" EnableEventValidation="false" AutoEventWireup="true" CodeFile="GridView_Export_Excel.aspx.cs" Inherits="GridView_Export_Excel" %>
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation;
- 只能在执行Render() 的过程中调用 RegisterForEventValidation
- 只能在执行Render() 的过程中调用 RegisterForEventValidation
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation
- 只能在执行Render() 的过程中调用 RegisterForEventValidation
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation;
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation
- 只能在执行Render()的过程中调用RegisterForEventValidation
- 只能在执行Render() 的过程中调用 RegisterForEventValidation
- 只能在执行Render() 的过程中调用 RegisterForEventValidation
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation(RegisterForEventValidation can only be called during Render(); )
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation(RegisterForEventValidation can only be called during Render()
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation(RegisterForEventValidation can only be called during Render(); )
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation(RegisterForEventValidation can only be called during Render();
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation(RegisterForEventValidation can only be called during Render(); )
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation(RegisterForEventValidation can only be called during Render()
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation(RegisterForEventValidation can only be called durin
- 基于轮廓的匹配算法(强,可在重叠堆积物体中识别)
- C#反射、动态生成类
- 小程序:学生信息管理系统--C语言版本
- ORACLE dba_free_space中没有要找的表空间名字
- 详解div+css相对定位和绝对定位用法
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation;
- 求文件大小的方法
- 使用OLEDB编程
- Android消息队列模型——Thread,Handler,Looper,Massage Queue
- SQL简单分页语句(支持SQL2005及以上)
- C# 动态生成类
- teradata with sql实例
- C# Group By
- C语言中产生随机数