到了HTTPClient上模拟ASPX表单提交

到了HTTPClient上模拟ASPX表单提交

本文介绍了到了HTTPClient上模拟ASPX表单提交 - 视图状态无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图模拟在一个ASPX.NET网站表单提交。

的网站的浏览器访问时,流程如下:

1)在浏览器的用户访问它配置了基本身份验证

2)在正确的凭据,向用户显示一个文本输入框和一个按钮(网址保持但提供服务的形式为Default.aspx的)

3)用户输入一些文字和presses提交...

4)重新加载页面...网址仍然是 ......但有哪些经过10秒触发和

我试图模拟使用我的程序了HTTPClient这一流程。

1)请在

一个GET

2)提取隐藏的表单字段__EVENTVALIDATION和__VIEWSTATE

3)创建与上述两者与其他表单字段的POST请求,并张贴到结果无效的视图状态的异常。

怎样在了HTTPClient?

实现这一目标
解决方案

通常的方法做,这是如下:首先,记录使用Wireshark的提琴手,或当您使用来自浏览器的网页的HTTP通讯。其次,详细分析数据包跟踪,并收集每一个HTTP头,并从浏览器发送的每一个GET和POST消息每个HTTP有效载荷。第三,尝试从code发送相同的消息。发送HTTP请求后,你将不得不分析服务器的响应,并提取你需要插入到下一个请求的所有数据块。不要忘记设置引荐字段,例如。一个每个请求添加到您的code之一,当你运行code记录的流量。如果你正确地组装您的HTTP请求,那么你的请求数据包应该像浏览器的请求。

I am trying to simulate a form submission on an ASPX.NET site.

The flow of the website when accessed in a browser is as follows:

1) In a browser the user visits http://mysite.com/ which is configured with Basic Authentication

2) Upon correct credentials, the user is shown a form with one input text box and a button (URL stays http://mysite.com/ but the form being served is Default.aspx)

3)User enters some text and presses submit...

4) The page reloads... URL is still http://mysite.com/... but there is a timer which triggers after 10 secs and downloads a file from http://mysite.com/Downloader

I am trying to simulate this flow in my program using HTTPClient.

1) Do a GET on http://mysite.com

2) Extract hidden form fields __EVENTVALIDATION and __VIEWSTATE

3) Create a POST request with above two and other form fields and POST it to http://mysite.com RESULTS in Invalid Viewstate exception.

How do I achieve this in HTTPClient?

解决方案

The usual way to do this is as follows: First, record the HTTP traffic using WireShark or Fiddler while you are using the website from the browser. Second, analyze the packet trace in detail, and collect every HTTP header and every HTTP payload from every GET and POST message sent by the browser. Third, try to send the same messages from your code. After sending an HTTP request, you will have to analyze the response of the server, and extract all pieces of data you need to insert into the next request. Don't forget to set the referer field, for example. Add each request to your code one by one, and record the traffic when you run the code. If you assemble your HTTP requests correctly, then your request packets should look like the requests of the browser.

这篇关于到了HTTPClient上模拟ASPX表单提交 - 视图状态无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 17:46