首页 > Windows开发 > 详细

WebApi_返回Post格式数据

时间:2017-12-13 22:51:38      阅读:286      评论:0      收藏:0      [点我收藏+]

 

   [HttpPost]
        public HttpResponseMessage Post([FromBody] DingTalkCallBack bodyMsg, string signature, string timestamp, string nonce)
        {
            var checkCode = ISVCallbackProvider.Instance.ISVCallback(bodyMsg.encrypt, signature, timestamp, nonce);
            var result = toJson(checkCode);
            return result;
        }
        public static HttpResponseMessage toJson(Object obj)
        {
            String str;
            if (obj is String || obj is Char)
            {
                str = obj.ToString();
            }
            else
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                str = serializer.Serialize(obj);
            }
            HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json") };
            return result;
        }

 

WebApi_返回Post格式数据

原文:http://www.cnblogs.com/sunzhenyong/p/8034419.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!