WebApi_返回Post格式数据

2021-07-24 17:54

阅读:550

标签: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


评论


亲,登录后才可以留言!