in reply to Re: Validation of viewstate MAC failed
in thread Validation of viewstate MAC failed

Hello,
Thank you,
I am taking the VIEWSTATE and the EVENTVALIDATION parameters to build the URL. When I copy_paste this very long URL to the Mozilla FireFox window (meaning that the URL is sent in GET method), it leads to the correct results page. But I can't send it in GET method from the command line in my server, using the basic Perl modules. When I try to do so I get the error:
Warning::(ml_lwp_wrapper): short write
I don't think I can change the GET request length limitation of the basic Perl modules.
So I'm trying to understand if I can overcome the VIEWSTATE validation error that I get, when I send the long URL in POST method.
  • Comment on Re^2: Validation of viewstate MAC failed

Replies are listed 'Best First'.
Re^3: Validation of viewstate MAC failed
by Marshall (Canon) on Nov 29, 2009 at 21:18 UTC
    Not quite sure what you are doing. "But I can't send it in GET method from the command line in my server" A VIEWSTATE can be HUGE, even 5KB or 10KB! Your command line buffer is probably a lot smaller than that! Maybe 1KB? Anyway I figure that VIEWSTATE is just too long to pass around as a command line parameter..it could just get truncated independent of what Perl can or cannot do. Past that, the VIEWSTATE is in general a dynamic thing that changes. I've not seen something that passes this around as a command line parm, hence my confusion. Yes, Post method can send a humongous thing.

    I would suggest that you post some code. Make the example as simple as possible to illustrate the behavior.

      Hello
      thank you for the help!
      I send several quires to the target site.
      first I send the URL of the home page.
      The ASP.NET sites usually have the VIEWSTATE parameter value in the HTML source of the home page or the main search page:
      <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJLTk4NTIyOT...==" />

      <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEW.." />

      I get the value of the VIEWSTATE and EVENTVALIDATION from the HTML source of the home page.
      I use uri_escape() to substituted the signs / " with the right values (%2F,%3D etc.), and use these parameters to recreate the URL that the target site sends for a search.
      The URL created looks something like this:
      THE_HOST_NAME_URL?__EVENTTARGET=&__EVENTARGUMENT= __VIEWSTATE=#THE_VIEW_STATE_PARAMETER#&THE_SEARCH_PARAMETERS&__EVENTVALIDATION=#THE_EVENT_VALIDATION_PARAMETER#
      I send this URL in a POST method,and instead of getting the results page, I get an error page:
      HttpException (0x80004005): Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that &lt;machineKey&gt; configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
      System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +160

      When I take the same URL and paste it in the Mozilla FireFox window, (its being sent in a GET method) I get to the results page.
      Any ideas on how to avoid the error page received when using the POST method?
      Thank you,