Using Http Post

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
 
J

Joerg Jooss

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top