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);
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章