如何使用HttpWebRequest发送自定义post请求
大侠指点.. 麻烦代码详细点 ..!!!
大侠指点.. 麻烦代码详细点 ..!!!
解决方案 »
- 线程问题,如何让一个对象只能打开一个线程
- jquery 添加 select <option>中添加项
- 请各位大侠来讨论下模板套用的问题~~~
- 在没有任何数据时进行无效的读取尝试....
- c# 二维数组的输入
- c#.net 2005的类视图窗口按鼠标右键没有出现方法向导等
- 请问一下有没有语句可以使得tabControl打开的时候显示的不是tabPage1,就是显示其他的tabPage?
- C# DataGridViewComboBoxColumn 赋值
- 正则式问题
- 谁能概括一下基类和子类的关系?面向对象的概念我还没掌握好。
- 在Timer中实现线程或用线程实现Timer控件?急
- 关于windows窗体的拉伸问题
public void PostXml(string url, string xml)
{
Stream requestStream = null;
try
{
byte[] bytes = Encoding.UTF8.GetBytes(xml);
request = (HttpWebRequest)WebRequest.Create(url);
request.Timeout = 1000000;
request.Method = "POST";
request.AllowWriteStreamBuffering = false;
request.KeepAlive = false;
request.ContentType = "text/xml";//类型你可以该为application/x-www-form-urlencoded
request.ContentLength = bytes.Length;
using (requestStream = request.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Flush();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
requestStream.Close();
}
}我要提交的是xml,你换成你想要上传的就可以了