request.ContentType = "application/json; charset=utf-8";
這種的postdata 在寫入 Stream的時候要確保編碼是 utf-8
string postData = "中文亂碼問題";
UTF8Encoding encoding = new UTF8Encoding();
byte[] bytepostData = encoding.GetBytes(postData);
request.ContentLength = bytepostData.Length;
//發送數據 using結束代碼段釋放
using (Stream requestStm = request.GetRequestStream())
{
requestStm.Write(bytepostData, 0, bytepostData.Length);
}
