How to send data ( fields ) to an URL?

This is a discussion on How to send data ( fields ) to an URL? within the C# Programming forums, part of the General Programming Boards category; How do I send some data to an URL? I seen some examples of "HttpWebRequest" but they all send only ...

  1. #1
    Registered User AloneInTheDark's Avatar
    Join Date
    Feb 2008
    Posts
    74

    How to send data ( fields ) to an URL?

    How do I send some data to an URL? I seen some examples of "HttpWebRequest" but they all send only one string of "data" to the URL.

    I need to send a couple of fields, like a big text field ( textarea like ) and other fields with names and values.

    any idéas?

    Edit : Solved, sort'a

    Found this on some site :


    Code:
    private void OnPostInfoClick(object sender, System.EventArgs e)
    {
    string strId = UserId_TextBox.Text;
    string strName = Name_TextBox.Text;
    
    ASCIIEncoding encoding=new ASCIIEncoding();
    string postData="userid="+strId;
    postData += ("&username="+strName);
    byte[] data = encoding.GetBytes(postData);
    
    // Prepare web request...
    HttpWebRequest myRequest =
    
    (HttpWebRequest)WebRequest.Create("http://localhost/MyIdentity/Default.aspx");
    myRequest.Method = "POST";
    myRequest.ContentType="application/x-www-form-urlencoded";
    myRequest.ContentLength = data.Length;
    Stream newStream=myRequest.GetRequestStream();
    // Send the data.
    newStream.Write(data,0,data.Length);
    newStream.Close();
    }
    Have not tested it but I'm gonna use XML instead so my problem is solved now.
    Last edited by AloneInTheDark; 02-12-2008 at 09:21 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. maximum data (bytes) send via socket ???
    By tritong in forum C Programming
    Replies: 6
    Last Post: 09-19-2006, 06:38 AM
  2. [question]Analyzing data in a two-dimensional array
    By burbose in forum C Programming
    Replies: 2
    Last Post: 06-13-2005, 08:31 AM
  3. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 11:28 PM
  4. can't insert data into my B-Tree class structure
    By daluu in forum C++ Programming
    Replies: 0
    Last Post: 12-05-2002, 06:03 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21