原创  C# POST数据到指定url并返回结果页面内容 收藏

using System.Net;
using System.Collections.Specialized;

....

public string getPostBackStream(string rUrl)
{
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();

// Create a new NameValueCollection instance to hold
// some custom parameters to be posted to the URL.

NameValueCollection myNameValueCollection = new NameValueCollection();

myNameValueCollection.Add("title","this is title");
myNameValueCollection.Add("url","http://test.mending.cn/tb_client.aspx");
myNameValueCollection.Add("excerpt","this is excerpt");

byte[] responseArray = myWebClient.UploadValues(rUrl,"POST",myNameValueCollection);
return Encoding.ASCII.GetString(responseArray);
}

发表于 @ 2009年01月18日 11:53:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:C# 断点续传原理与实现 (推荐) | 新一篇:C# 在采集数据时的验证与登录处理

  • 发表评论
  • 评论内容:
  •  
Copyright © fhbcn
Powered by CSDN Blog