桌面应用程序中,需要向服务器提交Http请求 桌面应用程序中,需要向服务器提交Http请求,该如何实现?请提供相关文档或代码示例,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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(); WebClient 可以完成Http交互,文件上传,下载之类 你要实现这样的功能,就写个WEB Service服务了操作 或者直接采用 xmlHttp对象 提交保存数据. dataGridView绑定table的问题 数据源更新后dataGridView不能刷新 C# and asp.net 中哪些类是不能被实例化的? 诚心求助各位高人,一个时间范围的算法? winform程序 中关于打包的一个小问题 私有静态变量有什么用呢? 机器没装office,怎么才能自动注册com组件. C#:嵌入的语句不能是声明或标记语句 C#: win form 中回车键的问题 请帮我看一下这段简单的利用ADO.NET删除记录的代码,为什么数据库内容没有改变? 如何在asp和aspx页面间传值或相互调用值呢? 关于数据库删除整行数据?
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();