社区
C#
帖子详情
提问:如何用C#做HTTP的POST方法请求
boymaster
2005-12-28 10:35:12
本人最初刚开始接触,请大虾们帮帮忙
C#如何用HTTP以text/plain方式来POST一个xml文件的内容!!!
在线期待中……
...全文
1025
14
打赏
收藏
提问:如何用C#做HTTP的POST方法请求
本人最初刚开始接触,请大虾们帮帮忙 C#如何用HTTP以text/plain方式来POST一个xml文件的内容!!! 在线期待中……
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
14 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
heilong05
2006-06-30
打赏
举报
回复
Encoding encoding = Encoding.GetEncoding("GB2312");
string strUrl = @"http://" + DefaultIP + "" + DefaultUrl + "";
string postData ="username="+UserName+"&password="+password+"&area_c=&telfile1="+TelePhones+"";
byte[] data = encoding.GetBytes(postData);
// 准备HTTP请求...
System.Net.HttpWebRequest myRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(strUrl);
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
System.IO.Stream newStream = myRequest.GetRequestStream();
// 发送数据
newStream.Write(data, 0, data.Length);
newStream.Close();
//HTTP响应
System.Net.HttpWebResponse myResponse = (System.Net.HttpWebResponse)myRequest.GetResponse();
System.IO.Stream receiveStream = myResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("GB2312");
System.IO.StreamReader readStream = new System.IO.StreamReader(receiveStream, encode);
Char[] read = new Char[256];
int count = readStream.Read(read, 0, 256);
StringBuilder sb = new StringBuilder("");
while (count > 0)
{
String readstr = new String(read, 0, count);
sb.Append(readstr);
count = readStream.Read(read, 0, 256);
}
myResponse.Close();
readStream.Close();
====CSDN 小助手 V2.5 2005年11月05日发布====
CSDN小助手是一款脱离浏览器也可以访问Csdn论坛的软件
界面:http://blog.csdn.net/Qqwwee_Com/archive/2005/11/05/523395.aspx
下载:http://szlawbook.com/csdnv2
固执的染色体
2006-06-30
打赏
举报
回复
mark
blackhero
2006-06-30
打赏
举报
回复
http://www.manbu.net/Lib/Class1/Sub8/1/24.asp
heilong05
2006-06-30
打赏
举报
回复
Mark
dreadknight2
2006-02-15
打赏
举报
回复
学习学习
Qqwwee_Com
2006-02-15
打赏
举报
回复
可以参考我尾巴后面的软件
有源代码的。
====CSDN 小助手 V2.5 2005年11月05日发布====
CSDN小助手是一款脱离浏览器也可以访问Csdn论坛的软件
界面:http://blog.csdn.net/Qqwwee_Com/archive/2005/11/05/523395.aspx
下载:http://szlawbook.com/csdnv2
jrl5365
2006-02-15
打赏
举报
回复
收下了!~以后可能用的着!
ArLi2003
2006-02-15
打赏
举报
回复
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfSystemNetWebClientClassUploadValuesTopic.htm
webclient 的 uploadXXXXXXXXXX 简单的很,不必webrequest
cmHua
2006-02-14
打赏
举报
回复
收藏起来慢慢看
singlepine
2005-12-29
打赏
举报
回复
http://singlepine.cnblogs.com/articles/292661.html
boymaster
2005-12-29
打赏
举报
回复
HttpWebRequest req = (HttpWebRequest) WebRequest.Create ( LMMPUrl ) ;
LMMPUrl直接写URL吗?类似:http://www.csdn.net吗?
atliu
2005-12-28
打赏
举报
回复
好像是孟子E章上的文章
atliu
2005-12-28
打赏
举报
回复
public static string PostData( string str)
{
try
{
byte[] data = System.Text.Encoding.GetEncoding ("GB2312").GetBytes ( str ) ;
// 准备请求...
HttpWebRequest req = (HttpWebRequest) WebRequest.Create ( LMMPUrl ) ;
req.Method = "Post" ;
req.ContentType ="application/x-www-form-urlencoded";
req.ContentLength = data.Length ;
Stream stream = req.GetRequestStream () ;
// 发送数据
stream.Write ( data ,0 ,data.Length ) ;
stream.Close () ;
HttpWebResponse rep = (HttpWebResponse)req.GetResponse();
Stream receiveStream = rep.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("GB2312");
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader( receiveStream, encode );
Char[] read = new Char[256];
int count = readStream.Read( read, 0, 256 );
StringBuilder sb = new StringBuilder ("") ;
while (count > 0)
{
String readstr = new String(read, 0, count);
sb.Append ( readstr ) ;
count = readStream.Read(read, 0, 256);
}
rep.Close();
readStream.Close();
return sb.ToString () ;
}
catch(Exception ex)
{
return "" ;
ForumExceptions.Log ( ex ) ;
}
}
s5689412
2005-12-28
打赏
举报
回复
参考MSDN中HttpWebRequest 和 HttpWebResponse 类的内容。
Sql 保留两位小数
使用 Round() 函数,如 Round(number,2) ,其中参数2表示保留两位有效数字,但是只负责四舍五入到两位小数,但是不负责截断 例如 ROUND(3.141591653, 2) 得到3.140000000; 使用 Convert(decimal(10,2),number) 实现转换,其中参数2表示保留两位有效数字 ...
SQL 保留两位小数的实现方式
SQL 保留两位小数的实现方式 SQL中保留两位小数的
方法
有三种,(第2、3种
方法
类似): 1、使用ROUND()函数,ROUND返回一个数值,舍入到指定的长度或精度,使用示例: SELECT ROUND(123.9994, 3) --123.9990 SELECT ROUND(123.9995, 3) --124.0000 SELECT ROUND(748.584, -1) --750.000 SELECT ROUND(748.586, -2) --700.000 SELECT ROUND
SQL保留两位小数,四舍五入
SQL 保留两位小数,四舍五入 转自
http
s://www.cnblogs.com/hao-1234-1234/p/8574188.html 一、问题描述 数据库里的 float momey 类型,都会精确到多位小数。但有时候 我们不需要那么精确,例如,只精确到两位有效数字。 二、解决: 1. 使用 Round() 函数,如 Round(@num,2) ,其中参...
sql 除法运算 保留两位小数
sql 除法运算 保留两位小数 SELECT 1530/60 select cast(1530*1./60 as decimal(18,1)) 转载于:
http
s://www.cnblogs.com/yachao1120/p/7593924.html
sql 四舍五入 保留两位小数
sql 四舍五入 保留两位小数一、问题描述二、sqlserver解决方案:三、CAST与CONVERT比较四、ROUND简单用法 一、问题描述 数据库里的 float momey 类型,都会精确到多位小数。但有时候 我们不需要那么精确,例如,只精确到两位有效数字。 二、sqlserver解决方案: 使用 Round() 函数,如 Round(@num,2) ,其中参数 2 表示 保留两位有效数字。 缺点:Round() 只是负责四舍五入到两位小数,但是不负责去掉后面的0。 print ROUND(13.
C#
111,129
社区成员
642,541
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章