NET Web API接收POST方式的JSON格式

测试接口的工具:postman,发送参数为JSON格式,发送方式为POST

Web API接收的方法:

        public string PostSaveData()
        {
            LogHelper.WriteLog("接口请求:" + Request.RequestUri.ToString());
            HttpRequest request =  HttpContext.Current.Request;
            Stream postData = request.InputStream;
            StreamReader sRead = new StreamReader(postData);
            string postContent = sRead.ReadToEnd();
            sRead.Close();
            LogHelper.WriteLog("接收到的数据:" + postContent);
            return postContent;
        }

posted @ 2019-01-19 14:23  漂移青春  阅读(275)  评论(0编辑  收藏  举报