加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 无效的回发或回调参数.为什么?

发布时间:2020-12-16 04:18:03 所属栏目:asp.Net 来源:网络整理
导读:所以我得到了例外 Invalid postback or callback argument. Event validation is enabled using in configuration or %@ Page EnableEventValidation=”true” % in a page. For security purposes,this feature verifies that arguments to postback or cal
所以我得到了例外

Invalid postback or callback argument.
Event validation is enabled using

in configuration or <%@ Page
EnableEventValidation=”true” %> in a
page. For security purposes,this
feature verifies that arguments to
postback or callback events originate
from the server control that
originally rendered them. If the data
is valid and expected,use the
ClientScriptManager.RegisterForEventValidation
method in order to register the
postback or callback data for
validation.

使用以下堆栈跟踪

[System.ArgumentException: Untrapped
Exception: Invalid postback or
callback argument. Event validation
is enabled using in
configuration or <%@ Page
EnableEventValidation=”true” %> in a
page. For security purposes,use the
ClientScriptManager.RegisterForEventValidation
method in order to register the
postback or callback data for
validation.] at
System.Web.UI.ClientScriptManager.ValidateEvent(String
uniqueId,String argument) at
System.Web.UI.Control.ValidateEvent(String
uniqueID,String eventArgument) at
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) at
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) at
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl,String eventArgument)
at
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData) at
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint,Boolean
includeStagesAfterAsyncPoint)

提交表单后出现异常,然后在页面重新加载之前快速单击LinkBut??ton以在同一页面上下载文件.

有人可以解释为什么在执行上述操作时发生此异常的细节?

提前致谢!

解决方法

这必须是.NET中最令人沮丧的错误消息之一,但是一旦你了解正在发生的事情,它就有意义了. .NET喜欢了解正在发生的一切.它跟踪它放置在页面上的所有元素.同样,当.NET收到来自它不知道的东西的输入时,它会被冒犯.在你的情况下,听起来,当你点击LinkBut??ton时,.NET认为它不应该在那里.根据我的经验,有两个可能的原因:

>您正在进行创建新输入或克隆现有输入的客户端方法.
>在处理表单提交时,.NET会对LinkBut??ton执行某些操作,导致它不再可用.我遇到的一些例子是你的LinkBut??ton是在后端动态创建的,或者你正在使用UpdatePanels,并且在表单提交过程中它们的内容会被更改.

基本上,我相信如果您单步执行表单提交代码并观察LinkBut??ton,您将看到.NET忘记它,当单击LinkBut??ton时可以理解地触发此“安全例外”.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读