Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EVENTVALIDATION error while scraping asp.net page

I need to get some values from this website. Basically I need to get the Area for every city. I am using Python and beautifulsoup for this. What I am doing is :

  1. First making a Get request to this page and getting __VIEWSTATE AND __EVENTVALIDATION to make a POST request to get cities for a particular state.Till here its working and I am getting cities for every states.

  2. To get Area I need to make another POST with new __VIEWSTATE AND __EVENTVALIDATION and this time i need to send city as well with other parameters.But I am getting error here:

505|error|500|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.|</pages>

I have checked each and every argument/parameter in firebug that I need to send to get areas for corresponding cities but no success. Maybe according to me problem is with __VIEWSTATE or __EVENTVALIDATION.

please help me

like image 783
user1170793 Avatar asked Dec 06 '25 10:12

user1170793


1 Answers

you have to get and pass the __VIEWSTATE and __EVENTVALIDATION variables in one session call, otherwise when doing the second POST call while reopening connection to the server it expects to receive back already another __VIEWSTATE and __EVENTVALIDATION!

So basically the logics should be as follows:

  • curl_init()
  • curl GET __VIEWSTATE and __EVENTVALIDATION
  • *some logics here *
  • curl POST parsed out __VIEWSTATE and __EVENTVALIDATION
  • * some logics here *
  • curl_close();
like image 195
user2047731 Avatar answered Dec 08 '25 01:12

user2047731



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!