4

This is the error

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.

and I'm also getting these just about as often

The state information is invalid for this page and might be corrupted.

I've read about 20 other "Invalid postback or callback argument" question & answers, and I don't think mine falls into any of the common categories:

  • Dynamically client-side created or changed controls that ASP.NET didn't know about
  • Users submitting code or bits of code, eg "<" and ">" characters
  • binding data in every Page_Load event without using if (!IsPostBack) judiciously
  • faulty AJAX CascadingDropDown extender
  • Russians trying to hack your site (!)
  • Intermittent issues on users with dialup (!)
  • Mismatch between ASP.NET versions, eg having a server farm with both ASP.NET 1.1 and 2.0 in use simultaneously

I THINK my issue's most similar to the last in this list.

I'm getting errors intermittently (but often) on my 2 Microsoft Azure web server load-balanced test environment upon form postbacks.

I notice the problem happens when a page produced by one of the servers is posted back to the other. When I take away the load balancing (just hitting one server only), the problem goes away.

I'm using Win Server 2008 R2 (IIS7.5) on one web server and Win Server 2012 (IIS8) on the other (I was familiar with 2008, and wary of 2012 but wanting to learn, so I chose to run one of each to hedge my bets, in case you're wondering).

The 2008 machine runs ASP.NET version "4.0.30319.272" and the 2012 one runs "4.0.30319.18010", but obviously different versions of IIS.

But they're both running ASP.NET 4.0. .NET is supposed to make the underlying operating system transparent, right? So I'm not that confident that this is causing the problem.

Re-building one server to make them the same would be quite a chore and would prefer to avoid it if the minor ASP.NET differences aren't the cause of the problem!

So are there any other reasons two servers won't accept each others' forms on postback? FYI, I've already added a entry into my web.config on both servers to fix "Validation of viewstate MAC failed" errors I was getting.

Or are there any config changes I could do to make the servers more compatible?

Thanks!

poshest
  • 4,157
  • 2
  • 26
  • 37
  • There is a "hash code" that is generated for your page and is post it back to ensure that no one is change various parameters on your page. If this code is different for any reason among your two machines then is fail. – Aristos Feb 03 '13 at 21:11
  • To check if you have different validation on the two computers check two pages that come from each one and see the `__EVENTVALIDATION` entry. Must be the same. If not then this is the issue. Ensure that the `machineKey` have the same validationKey and validation algorithm on both computers. – Aristos Feb 03 '13 at 21:14
  • @Aristos - Yes, machineKey has identical validationKey and validation algorithm on both computers. But the `__EVENTVALIDATION` entry comes back very differently from each of them. From the Win2012 server, `__EVENTVALIDATION` is more than twice as long too. I'll keep investigating. – poshest Feb 04 '13 at 18:03
  • User Levi posted a comment on this http://stackoverflow.com/questions/14372009/asp-net-eventvalidation-fails-when-net-4-5-framework-is-installed-in-only-one-s. Seems like he knows a thing or two about the innards of ASP.NET Viewstate. Any chance I can get his attention by going @Levi? Or does this only work for commenters on this question? – poshest Feb 04 '13 at 19:33

3 Answers3

3

So I spent the half day re-building my web "farm" and making both servers 2008R2, and the problem went away!

My (tentative) conclusion is that the differences between viewstate handling between .NET 4.0.30319... versions on Server 2008R2 vs 2012 (including the completely different __EVENTVALIDATION format) were the cause of the problem.

I can't be certain of that because maybe the way I set the 2012 server up was different to the 2008R2 server. But then, when building the 2012 server, I followed fairly strictly the 2008R2 build document I'd written, so that, as well as the 2 days I spent tinkering the builds to get it to work, raises my confidence that I didn't miss something obvious.

Moral of the story (at about 80% confidence): don't mix server versions in ASP.NET deployments, even if the version of .NET is the same.

poshest
  • 4,157
  • 2
  • 26
  • 37
0

I had the same problem Farm system. I tested several solutions and what worked was:

  • Generate the machineKey on one system and then replicate to another. (I found in several forums this solution, but it alone does not work)
  • Put the same type of compability. For me it was "Framework45". (From this configuration started to work).

Example:

<system.web>
...
<machineKey compatibilityMode="Framework45" decryptionKey="808A25F38661B8799CFD5B6FC5CF73D2988F5786CE46075D" validationKey="B75D59843CA111DF8596FCF865D9C0459B63B6ED474D4B23FD63A5F3A5AB18560A0D2A162191EC3354650CB37B174DDE187B29D424FC5CF60EFDA567BA64D3A3" />
...
</system.web>
-5

Try putting following in your page directive-

<%@ Page EnableEventValidation="false" %>
Microsoft DN
  • 9,706
  • 10
  • 51
  • 71
  • 2
    Yes, I saw that answer many times in the other answers, along with the many recommendations NOT to use it. I really want the security benefits that come with Event Validation. – poshest Feb 04 '13 at 18:07