桌面应用程序中,需要向服务器提交Http请求,该如何实现?请提供相关文档或代码示例,谢谢!

解决方案 »

  1.   

    string strTitle = TextBox1.Text;
    string strDesc = TextBox2.Text;Encoding encoding = Encoding.GetEncoding("GB2312");string postData = "Title=" + strTitle;
    string strUrl = "http://xml.sz.luohuedu.net/HttpReceiveData.aspx";
    postData += ("&Desc=" + strDesc);
    byte[] data = encoding.GetBytes(postData);// 准备请求...
    HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(strUrl);
    myRequest.Method = "POST";
    myRequest.ContentType="application/x-www-form-urlencoded";
    myRequest.ContentLength = data.Length;
    Stream newStream=myRequest.GetRequestStream();
    // 发送数据
    newStream.Write(data,0,data.Length);
    newStream.Close();
      

  2.   

    WebClient 可以完成Http交互,文件上传,下载之类
      

  3.   

    你要实现这样的功能,就写个WEB Service服务了操作
      

  4.   

    或者直接采用 xmlHttp对象 提交保存数据.