技术文章 > POST数据到指定url并返回结果页面内容

POST数据到指定url并返回结果页面内容

2018-04-26 17:17

文档管理软件,文档管理系统,知识管理系统,档案管理系统的技术资料:
[code]
csharp
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);
}
[/code]