分润宝,专注各种代理商分润系统开发!完美兼容各支付公司产品代理商分润结算模式。
全国服务热线0592-5519259 在线咨询 微信咨询

分润宝 手机端

在线客服

技术文档 > 技术文档

asp.net客户端POST提交JSON数据

private string HttpPost(string Url, string postDataStr)
 {
     HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
     request.Method = "POST";
     request.ContentType = "application/json";
     request.ContentLength = Encoding.UTF8.GetByteCount(postDataStr);
     Stream myRequestStream = request.GetRequestStream();
     StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("gb2312"));
     myStreamWriter.Write(postDataStr);
     myStreamWriter.Close();
     HttpWebResponse response = (HttpWebResponse)request.GetResponse();
     Stream myResponseStream = response.GetResponseStream();
     StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
     string retString = myStreamReader.ReadToEnd();
     myStreamReader.Close();
     myResponseStream.Close();
     return retString;
}

如果没有解决您的问题,请立即联系客服

声明:文章"asp.net客户端POST提交JSON数据"为分润宝原创文章,转载请注明出处,谢谢合作!

分润宝公众号

客服

微信客服

置顶