都一样。找个http请求工具。
最简单的就是webclient了。new一个看看他的方法就可以了。也可以百度下
对着这个翻译成C#代码就可以了
public static string HttpPost(string strURL, string strParm, int timeOut)
{
StringBuilder rStr = new StringBuilder();
try
{
byte[] postBytes = Encoding.ASCII.GetBytes(UrlEncodeGB2312(strParm));
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(strURL);
request.Timeout = timeOut;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postBytes, 0, postBytes.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader streamReader = new StreamReader(responseStream, Encoding.Default);
while (streamReader.Peek() != -1)
{
rStr.Append(streamReader.ReadLine());
}
streamReader.Close();
response.Close();
}
catch { }
return rStr.ToString();
}
}