[Dead]How to successfully POST to an old ASP.NET site utilizing Asynchronous Postback [Dead]How to successfully POST to an old ASP.NET site utilizing Asynchronous Postback curl curl

[Dead]How to successfully POST to an old ASP.NET site utilizing Asynchronous Postback


A. You state in your request that you are Firefox browser:

curl_setopt($cl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0');

Do not claim you're Firefox:

  • if you cannot process scripts (as Firefox can and does)
  • if you want to prevent ASP.NET from sending you a partial rendering response

Make your own user agent name, or don't send it at all.

ASP.NET checks if user agent supports callbacks:HttpCapabilitiesBase.SupportsCallback Property

B. Don't send __ASYNCPOST = true (give it a try).


Here you are an addapted approach that works for me:

    public function doPostbackToAspDotNetPage(){    $uri = '*** THE_URL ***';    $cl = curl_init();    curl_setopt($cl, CURLOPT_URL, $uri);    curl_setopt($cl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:54.0) Gecko/20100101 Firefox/54.0');    curl_setopt($cl, CURLOPT_COOKIESESSION, '*** OPTIONAL ***');    curl_setopt($cl, CURLOPT_FOLLOWLOCATION, 1);    curl_setopt($cl, CURLOPT_RETURNTRANSFER, 1);    curl_setopt($cl, CURLOPT_CONNECTTIMEOUT, 0);    curl_setopt($cl, CURLOPT_POST, 1);    // Just in case the url is https and the certification gives some kind of error    curl_setopt($cl, CURLOPT_SSL_VERIFYHOST, false);    curl_setopt($cl, CURLOPT_SSL_VERIFYPEER, false);    $postdata = array(        '__EVENTTARGET' => '*** A value such as: SOME_ID$ctl20$ctl02 ***',        '__EVENTARGUMENT' => ' *** OPTIONAL ***',        "__VIEWSTATE" => '*** REQUIRED BUNCH OF CHARACTERS ***',        "__ASYNCPOST" => "true",        '__VIEWSTATEGENERATOR' => '*** OPTIONAL ***',        '__EVENTVALIDATION' => "*** REQUIRED BUNCH OF CHARACTERS ***",    );    curl_setopt($cl, CURLOPT_POSTFIELDS, $postdata);    $result = curl_exec($cl);    if (!$result) {        echo sprintf('ERROR:%s', PHP_EOL);        echo curl_error($cl);    } else {        echo $result;    }    curl_close($cl);}


A different approach can be use a very useful PHP tool (a class emulating browser behavior) that do all the job to keep trace of all fields, do the post/get by clicking on links or buttons.

Here the link:

simpletest