3

I want using httpWebRequest to "POST" data to a website. So i used firebug analyzing what really send to server. 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). 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)?

Thanks you for all supports

cao_bang
  • 199
  • 1
  • 4
  • 17
  • 1
    possibly ? http://stackoverflow.com/questions/726710/fake-a-form-submission-with-c-sharp-webclient – Hardrada Nov 09 '12 at 04:20

1 Answers1

4

You create the HttpWebRequest object, get the request stream, and write your parameters to it. The example at HttpRequest.GetRequestStream should point you in the right direction.

Jim Mischel
  • 131,090
  • 20
  • 188
  • 351
  • follow the example you give, i must set my string postData = "param1=&param2=&param3=defautl_value1&param4=default_value2&param5=value_I_set_‌​byhand1&param6=value_I_set_byhand2"; or postData = "param3=defautl_value1&param4=default_value2&param5=value_I_set_byhand1&param6=v‌​alue_I_set_byhand2" or postData = "param5=value_I_set_byhand1&param6=value_I_set_byhand2"???? – cao_bang Nov 10 '12 at 00:46