You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.4 KiB
40 lines
1.4 KiB
2 years ago
|
using System.Net;
|
||
|
using System.Text;
|
||
|
|
||
|
namespace Znyc.CloudCar.Utility.Helper
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 模拟标准表单Post提交
|
||
|
/// </summary>
|
||
|
public class HttpHelper
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 模拟标准表单Post提交
|
||
|
/// </summary>
|
||
|
/// <param name="url"></param>
|
||
|
/// <param name="postdate"></param>
|
||
|
/// <returns></returns>
|
||
|
public static string PostSend(string url, string postdate)
|
||
|
{
|
||
|
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
|
||
|
myHttpWebRequest.Method = "POST";
|
||
|
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
|
||
|
myHttpWebRequest.Method = "POST";
|
||
|
Stream stream = myHttpWebRequest.GetRequestStream();
|
||
|
StreamWriter writer = new StreamWriter(stream);
|
||
|
writer.Write(postdate);
|
||
|
writer.Flush();
|
||
|
writer.Close();
|
||
|
stream.Close();
|
||
|
|
||
|
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
|
||
|
Stream myResponseStream = myHttpWebResponse.GetResponseStream();
|
||
|
StreamReader streamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
|
||
|
string response = streamReader.ReadToEnd();
|
||
|
streamReader.Close();
|
||
|
myHttpWebResponse.Close();
|
||
|
return response;
|
||
|
}
|
||
|
}
|
||
|
}
|