[Dead]如何使用异步Postback成功地发布到一个旧的ASP.NET网站 [英] [Dead]How to successfully POST to an old ASP.NET site utilizing Asynchronous Postback

查看:297
本文介绍了[Dead]如何使用异步Postback成功地发布到一个旧的ASP.NET网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[更新]不幸的是,我从来没有机会解决这个问题。但是,下面有一些有趣的反应是值得尝试的其他读者寻找做类似的东西。

[Update] Unfortunately I never had an opportunity to solve this problem. However, there are some interesting responses below that are worth a try for other readers looking to do something similar.

我试图解析来自运行ASP的网站的数据。净。这个网站有一个登录页面,我已成功地通过(使用合法的帐户)并存储cookie,但是当我深入到网站,我需要通过更新UpdatePanels通过异步Postbacks导航。 UpdatePanels包含我想要的数据。

I'm trying to parse data from a site running ASP.NET. This site has a login page that I've successfully traversed (using a legitimate account) and stored the cookie for, but when I get deeper into the site I need to navigate it by updating UpdatePanels via Asynchronous Postbacks. The UpdatePanels contain the data that I want.

我想使用PHP和curl做这一切。我可以成功加载初始页面。当我通过所有相关数据(通过Firefox的Tamper Data插件获取)到我的目标页面时,curl返回的回显结果总是清除我的页面。通常,回显结果只会在页面的下方打印出来(或者喷出一些错误/乱码文本)。 curl_error()不打印出任何东西,所以返回给我的东西有问题。

I'm trying to do this all using PHP and curl. I can successfully load the initial page. When I POST to my target page with all the relevant data (obtained via Firefox's Tamper Data plugin), the echoed result returned from curl always clears my page. Typically, echoing the result would just print out (or spew some error/garbled text) further down the page. curl_error() doesn't print out anything, so it's something wrong with what's being returned to me.

我在wits结束了如何从这里。请告诉我如果:a)你知道我得到什么错误,b)如果这甚至可能与专有PHP,和c)如果,相反,我需要刷掉javascript与ASP.NET的UpdatePanels 。

I'm at wits end about how to go about this from here. Please tell me if: a) you know what error I'm getting, b) if this is even going to be possible with exclusively PHP, and c) if, conversely, I need to brush off javascript to interact with ASP.NET's UpdatePanels.

$uri = "TARGETURL";
$cl=curl_init();
curl_setopt($cl, CURLOPT_URL, $uri);
curl_setopt($cl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0');
curl_setopt($cl, CURLOPT_COOKIEFILE, "/tmp/cookie2.txt");
curl_setopt($cl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($cl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cl, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($cl, CURLOPT_POST, 1);
$postdata=array(

    "__VIEWSTATE" => $viewstate,
    "OTHER DATA" => "asdfkljsddflkjshdjf",
    "__ASYNCPOST" => "true",
);
echo "<PRE>";
print_r($postdata);
echo "</PRE>";
curl_setopt ($cl, CURLOPT_POSTFIELDS, $postdata);
$result = curl_exec($cl); // execute the curl command
echo $result;

这是我从服务器收到的标题和正文使用echo语句进行页面清除):

Here is the Header and Body I am receiving back from the server (e-mailed to myself to bypass the page-clearing happening with the echo statement):

HEADER RESPONSE: 
HTTP/1.1 100 Continue 
HTTP/1.1 200 OK 
Cache-Control: no-cache 
Pragma: no-cache 
Content-Type: text/plain; charset=utf-8
Expires: -1 
Server: Microsoft-IIS/7.5 
X-Content-Type-Options: nosniff
Set-Cookie: culture=en-US; expires=Tue, 27-Nov-2012 20:02:37 GMT; path=/ 
X-Powered-By: ASP.NET Date: Mon, 28 Nov 2011 20:02:37 GMT
Content-Length: 112 
BODY RESPONSE: 
69|dataItem||<script type="text/javascript">window.location="about:blank"</script>|11|pageRedirect||/Error.aspx|

这解释了我得到的问题,页面空白(javascript重定向我的浏览器输出)。它也似乎表明头是不是问题,因为我从错误的头值得到一个HTTP错误。

This explains the problem I'm getting with the page going blank (javascript redirecting my browser output). It also seems to indicate that the header isn't the issue as I'd be getting an HTTP error from bad header values.

推荐答案

p> A。您在请求中说明您是Firefox浏览器:

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');

不要声称您是Firefox:

Do not claim you're Firefox:


  • 如果您不能处理脚本(如Firefox可以和不会)

  • 部分呈现响应

创建自己的用户代理名称,或根本不发送。

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

ASP.NET检查用户代理是否支持回调:
HttpCapabilitiesBase.SupportsCallback属性

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

B。不要发送 __ ASYNCPOST = true (试试)。

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

这篇关于[Dead]如何使用异步Postback成功地发布到一个旧的ASP.NET网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆