.Net – ASPX – Error – “Invalid postback or callback argument. Event validation is enabled”

Background

Tried using a dated .Net Application that I wrote quite a long time ago.

I accessed a drop down, selected an item from the drop down, and clicked a push button.

Errors

Error – “Invalid postback or callback argument. Event validation is enabled using…”

Unfortunately received an error that reads:-

Text

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.

Image

Troubleshooting

The error reads:-

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation=”true”/> in configuration or <%@ Page EnableEventValidation=”true” %> in a page.

It appears that:-

  1. System Wide
    • Web.Config
      • It appears that we have an entry in the web configuration file that is enabling enableEventValidation
  2. Specific Web Page
    • We have “EnableEventValidation” set to true on our specific faulting page

 

Remediation

Page

Checked the ASPX Page and confirmed that we do not have a page directive that references EnableEventValidation.

 

Web.Config

Outline

  1. Disabled Request Validation system wide.

Code

 

<system.web> 

<!-- 
   added on 2022-06-19 10:22 PM by dadeniji 
   to address error "Invalid postback or callback argument" 
--> 

<pages validateRequest="false" /> 

</system.web> 

Advisory

Web.Config

enableViewStateMac

Disable enableViewStateMac

One of the posters to a related StackOverfow Q/A post suggested disabling enableViewStateMac.

That option is no longer valid.

Please read more here:-

  1. Microsoft
    • Microsoft .NET
      • Levi Broderick
        • Farewell, EnableViewStateMac!
          Authored On:- September 9th, 2014
          Link

 

References

  1. Stack Overflow
    • A potentially dangerous Request.Form value was detected from the client
      Link

Summary

The error seems to only occur a only the first few times one self posts to a page.

One can live with it.

If you choose to make the change please be conservative.

  1. Understand the implications of setting validateRequest off
  2. Backup the website artifacts
  3. Make the change
  4. Monitor to make sure that the error is indeed addressed
  5. Determine whether you have introduced other concerns or errors

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s