码迷,mamicode.com
首页 > Windows程序 > 详细

WebApi_返回Post格式数据

时间:2017-12-13 23:25:39      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:timestamp   return   div   log   post   from   code   serialize   signature   

 

   [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格式数据

标签:timestamp   return   div   log   post   from   code   serialize   signature   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!