Using Http Post

  • Thread starter Thread starter Yogesh
  • Start date Start date
Y

Yogesh

Hi all
I want to do Http POST from C# application i m using webclient for that .
Mi prob is when i am posting data i need to fire Button1_Click event which
is not firing .
Like this is client Code
WebClient myWebClient = new WebClient() ;

req.ContentType = "application/x-www-form-urlencoded";

req.Method = "POST";

NameValueCollection Coll = new NameValueCollection() ;

Coll.Add("TextBox1" ,"ram") ;

Coll.Add("TextBox2" ,"Shyam") ;

Coll.Add("Button1" ,"Button") ;


byte[] responseArray =
myWebClient.UploadValues("http://192.168.96.33/TestPost/WebForm1.aspx","POST
",Coll);


MessageBox.Show(System.Text.Encoding.ASCII.GetString(responseArray));





On server ther e is event

private void Button1_Click(object sender, System.EventArgs e)

{

TextBox1.Text = "Yogesh" ;

Response.Write(TextBox1.Text + TextBox2.Text) ;



}



I need to call this event



Thanks in advance



Yogesh
 
Thus wrote Yogesh,
Hi all
I want to do Http POST from C# application i m using webclient for
that .
Mi prob is when i am posting data i need to fire Button1_Click event
which
is not firing .
Like this is client Code
WebClient myWebClient = new WebClient() ;
req.ContentType = "application/x-www-form-urlencoded";

req.Method = "POST";

NameValueCollection Coll = new NameValueCollection() ;

Coll.Add("TextBox1" ,"ram") ;

Coll.Add("TextBox2" ,"Shyam") ;

Coll.Add("Button1" ,"Button") ;

byte[] responseArray =
myWebClient.UploadValues("http://192.168.96.33/TestPost/WebForm1.aspx"
,"POST ",Coll);

MessageBox.Show(System.Text.Encoding.ASCII.GetString(responseArray));

On server ther e is event

private void Button1_Click(object sender, System.EventArgs e)

{

TextBox1.Text = "Yogesh" ;

Response.Write(TextBox1.Text + TextBox2.Text) ;

}

Make sure to post the same data a browser would post (including ViewState
and other hidden fields), and all HTTP headers like User-Agent, Accept-Language
etc.

Cheers,
 
Back
Top