使用HTTPS 调用,发现输入什么关键字都返回 0,ok
代码如下:这个需要转格式?
public JsonResult> PostmsgSecCheck(Content content)
{
var ret = Security.msgSecCheck(content.Body);
return JsonResult(new
{
errcode = ret.errcode,
errmsg = ret.errmsg
});
}
public dynamic msgSecCheck(string content)
{
var msg = new { content };
string jsonString = HttpHelper.HttpPost(url, JsonConvert.SerializeObject(msg));
var json = JsonConvert.DeserializeObject(jsonString);
return new
{
json.errcode,
json.errmsg
};
}
public static string HttpPost(string Url, string postDataStr)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
request.Method = "POST";
//request.ContentType = "application/x-www-form-urlencoded";
request.ContentType = "application/json";
request.ContentLength = postDataStr.Length;
StreamWriter writer = new StreamWriter(request.GetRequestStream(), Encoding.ASCII);
writer.Write(postDataStr);
writer.Flush();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string encoding = response.ContentEncoding;
if (encoding == null || encoding.Length < 1)
{
encoding = "UTF-8"; //默认编码
}
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
string retString = reader.ReadToEnd();
return retString;
}
请问问题解决了吗