Using Http Post

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yogesh

    #1

    Using Http Post

    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 = "applicatio n/x-www-form-urlencoded";

    req.Method = "POST";

    NameValueCollec tion Coll = new NameValueCollec tion() ;

    Coll.Add("TextB ox1" ,"ram") ;

    Coll.Add("TextB ox2" ,"Shyam") ;

    Coll.Add("Butto n1" ,"Button") ;


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


    MessageBox.Show (System.Text.En coding.ASCII.Ge tString(respons eArray));





    On server ther e is event

    private void Button1_Click(o bject sender, System.EventArg s e)

    {

    TextBox1.Text = "Yogesh" ;

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



    }



    I need to call this event



    Thanks in advance



    Yogesh


  • Joerg Jooss

    #2
    Re: Using Http Post

    Thus wrote Yogesh,
    [color=blue]
    > 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 = "applicatio n/x-www-form-urlencoded";
    >
    > req.Method = "POST";
    >
    > NameValueCollec tion Coll = new NameValueCollec tion() ;
    >
    > Coll.Add("TextB ox1" ,"ram") ;
    >
    > Coll.Add("TextB ox2" ,"Shyam") ;
    >
    > Coll.Add("Butto n1" ,"Button") ;
    >
    > byte[] responseArray =
    > myWebClient.Upl oadValues("http ://192.168.96.33/TestPost/WebForm1.aspx"
    > ,"POST ",Coll);
    >
    > MessageBox.Show (System.Text.En coding.ASCII.Ge tString(respons eArray));
    >
    > On server ther e is event
    >
    > private void Button1_Click(o bject sender, System.EventArg s e)
    >
    > {
    >
    > TextBox1.Text = "Yogesh" ;
    >
    > Response.Write( TextBox1.Text + TextBox2.Text) ;
    >
    > }
    >[/color]

    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,
    --
    Joerg Jooss
    news-reply@joergjoos s.de


    Comment

    Working...