[WebMethod]
public void TestAPI()
{
Stream stream = HttpContext.Current.Request.InputStream;
stream.Position = 0;
StreamReader streamReader = new StreamReader(stream);
string data = streamReader.ReadToEnd();
Result result = POST(data);
var mm = new { Code = result.errorCode, Msg = result.Msg };
HttpContext.Current.Response.Charset = "gb2312"; //设置字符集类型
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
HttpContext.Current.Response.Write(mm);
HttpContext.Current.Response.End();
}
Stream stream = HttpContext.Current.Request.InputStream;
stream.Position = 0;
StreamReader streamReader = new StreamReader(stream);
string data = streamReader.ReadToEnd();
这四行就是根据Request获取的json格式的参数,超好用,超好用,超好用!!!