每当用户在我的Web应用程序中发布包含<或>在页面中的内容时,我都会抛出此异常.
我不想进入关于抛出异常或崩溃整个Web应用程序的聪明性的讨论,因为有人在文本框中输入了一个字符,但我正在寻找一种优雅的方法来处理这个问题.
捕获异常并显示
发生错误请返回并重新输入整个表单,但这次请不要使用<
对我来说似乎不够专业.
禁用post validation(validateRequest="false")肯定会避免此错误,但它会使页面容易受到许多攻击.
理想情况:当发回包含HTML限制字符的回发时,Form集合中的已发布值将自动进行HTML编码.所以.Text我的文本框的属性将是something & lt; html & gt;
有没有办法可以从处理程序中执行此操作?
我收到此错误:
Server Error in '/' Application.
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> 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.
Description: An unhandled exception occurred during the execution …Run Code Online (Sandbox Code Playgroud) 好的,所以我在gridview中有一个只包含一个简单按钮的模板字段......
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Administration.aspx.cs"
Inherits="Administration" %>
<%@ Register TagPrefix="ajaxToolkit" Namespace="AjaxControlToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Keywords Administration</title>
</head>
<body class="popupbody">
<form id="form1" runat="server">
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnablePartialRendering="true" CombineScripts="false"></ajaxToolkit:ToolkitScriptManager>
<asp:Label ID="AddLabel" runat="server">Add a Keyword</asp:Label>
<br />
<asp:TextBox ID="AddTextBox" runat="server" />
<asp:Button ID="AddButton" Text="Add" runat="server" OnClick="AddKeyword_Click" />
<asp:GridView ID="KeywordsGridView" AllowPaging="false" AutoGenerateColumns="false" BackColor="white"
GridLines="None" HeaderStyle-CssClass="Table_Header" RowStyle-CssClass="Table_Style"
OnRowDataBound="RowBound" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="References" SortExpression="References" HeaderText="Total References" />
<asp:BoundField …Run Code Online (Sandbox Code Playgroud) 我有两个下拉列表,我使用javascript基于另一个填充一个.在我的javascript代码中,我正在调用webservice并返回结果,我填写了另一个下拉列表.问题是,在我成功完成后,开始出现以下错误:
无效的回发或回调参数.使用配置或页面中的<%@ Page EnableEventValidation ="true"%>启用事件验证.出于安全考虑,此功能可验证回发或回调事件的参数是否来自最初呈现它们的服务器控件.如果数据有效且符合预期,请使用ClientScriptManager.RegisterForEventValidation方法注册回发或回调数据以进行验证.
任何的想法 ?
从2.0迁移到.net 4.5.1后我有这个错误
无效的回发或回调参数.使用配置或页面中的<%@ Page EnableEventValidation ="true"%>启用事件验证.出于安全考虑,此功能可验证回发或回调事件的参数是否来自最初呈现它们的服务器控件.如果数据有效且符合预期,请使用ClientScriptManager.RegisterForEventValidation方法注册回发或回调数据以进行验证.
[ArgumentException:无效的回发或回调参数.使用配置或页面中的<%@ Page EnableEventValidation ="true"%>启用事件验证.出于安全考虑,此功能可验证回发或回调事件的参数是否来自最初呈现它们的服务器控件.如果数据有效且符合预期,请使用ClientScriptManager.RegisterForEventValidation方法注册回发或回调数据以进行验证.]
System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId,String argument)+144
System.Web.UI .Control.ValidateEvent(String uniqueID,String eventArgument)+111
System.Web.UI.WebControls.DropDownList.LoadPostData(String postDataKey,NameValueCollection postCollection)+55
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler .LoadPostData(String postDataKey,NameValueCollection postCollection)+16
System.Web.UI.Page.ProcessPostData(NameValueCollection postData,Boolean fBeforeLoad)+303
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+1593
我可以做什么?
我在localhost上有这个问题,但如果我尝试远程访问它,问题就解决了(在另一个工作站上).如果同事试图在他的电脑(对我工作的那个)上访问它,他们会遇到同样的问题,但如果他们使用我的工作站,该应用程序工作.
asp.net ×5
c# ×3
javascript ×2
validation ×2
asp.net-mvc ×1
callback ×1
gridview ×1
html ×1
html-encode ×1
postback ×1
request.form ×1