1. 程式人生 > >WebApi_返回Post格式數據

WebApi_返回Post格式數據

stat ide javascrip code bject () static nco pre

   [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格式數據