简体   繁体   English

如何使用httpWebRequest设置请求体

[英]how to set up request body with httpWebRequest

I want using httpWebRequest to "POST" data to a website. 我想使用httpWebRequest将数据“POST”到网站。 So i used firebug analyzing what really send to server. 所以我使用firebug分析真正发送给服务器的内容。 First step, i use browser to browsing www.mytargetURL.net, second, turn on firebug, after that, i fill all form data and click the submit button (it's mean POST data to the server). 第一步,我使用浏览器浏览www.mytargetURL.net,第二步,打开firebug,之后,我填写所有表单数据并单击提交按钮(这意味着POST数据到服务器)。 So, I watching firebug and there was a lot of Parameters in request body part. 所以,我看萤火虫,请求身体部分有很多参数。 Something like: 就像是:

param1=
param2=
param3=default_value1
param4=default_value2
param5=value_I_set_byhand1
param6=value_I_set_byhand2

The question is: I should set up the request body of httpWebRequest obj with all the parameters i saw in firebug parameter table (it's mean all 6 parameters) or just parameters which has value (parameter 3-6) or just parameters i have filled in the submit form(just param5 and param6)? 问题是:我应该设置httpWebRequest obj的请求体,其中包含我在firebug参数表中看到的所有参数(它意味着所有6个参数)或者只是具有值的参数(参数3-6)或者我填写的参数提交表单(只是param5和param6)?

Thanks you for all supports 谢谢你的支持

You create the HttpWebRequest object, get the request stream, and write your parameters to it. 您可以创建HttpWebRequest对象,获取请求流,并将参数写入其中。 The example at HttpRequest.GetRequestStream should point you in the right direction. HttpRequest.GetRequestStream中的示例应该指向正确的方向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM