5

結果のリストを DataGrid または ASP.Net Repeater として表示し、結果のページングを行う ASP.Net ホスト Web サイトがあります。

前/次のタブを押してページをすばやくスクロールすると、HttpUnhandledException がスローされ、結果の次のリストの代わりにデバッグ ページがレンダリングされることがあります。

デバッグ画面は次のとおりです。

System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: 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.
  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)
  --- End of inner exception stack trace ---
  at System.Web.UI.Page.HandleError(Exception e)
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  at System.Web.UI.Page.ProcessRequest()
  at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
  at System.Web.UI.Page.ProcessRequest(HttpContext context)
  at ASP.contacts_default_aspx.ProcessRequest(HttpContext context)
  at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
  at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

http://blogs.msdn.com/amitsh/archive/2007/07/31/why-i-get-invalid-postback-or-callback-argument-errors.aspxで、このようなエラーへの参照を見つけました。

推奨される解決策は false に設定することですが、これはセキュリティ ホールを作成するようです。コメントではいくつかの代替案が推奨されていますが、サイト全体で使用されているすべての DataGrid または Repeater コントロールにコードを追加する必要があるため、すべてがかなり複雑に見えます。

セキュリティを犠牲にすることなく実行できる、より一般的なソリューションはありますか?

4

1 に答える 1

9

ページの非表示フィールドは、ポストバックでは提供されません。これらのフィールドはいくつかあり、通常、ASP.Netが提供する「魔法」に必要です。

ページディレクティブで、ページディレクティブにenableEventValidation = falseを入れてオフにすることができますが、これは望ましくない場合があります

書き込みコードを移動して、要素をページの上部に移動できます

最後に、この正確な問題は最近ServicePackまたは3.5で修正されたと確信しています。

- 編集 -

設定が見つかりました:RenderAllHiddenFieldsAtTopOfForm

MSDNによると、次のバージョンでサポートされています:3.5 SP1、3.0 SP2、2.0 SP2

于 2008-12-02T18:55:24.957 に答える