
        public ActionResult ccbwx_notifyurl()
         {
                #region 请求参数
                 Hashtable has = new Hashtable();
                 System.Collections.Specialized.NameValueCollection collection;
                 //if (this.HttpContext.Request.HttpMethod.ToUpper() == "POST")
                 //{
                 collection = this.HttpContext.Request.Form;
                 foreach (string k in collection)
                 {
                     string v = (string)collection[k];
                     if(!has.ContainsKey(k))
                     {
                         has.Add(k, v);
                     }
                    
                 }
                 //}
                collection = this.HttpContext.Request.QueryString;
                 foreach (string k in collection)
                 {
                     string v = (string)collection[k];
                     if (!has.ContainsKey(k))
                     {
                         has.Add(k, v);
                     }
                 }
                 try
                 {
                     if (this.HttpContext.Request.InputStream.Length > 0)
                     {
                         #region body=raw、binary
                         try
                         {
                            Int32 strLen, strRead;
                             System.IO.Stream str = Request.InputStream;
                             strLen = Convert.ToInt32(str.Length);
                             byte[] strArr = new byte[strLen];
                             strRead = str.Read(strArr, 0, strLen);
                            String strmContents = System.Text.Encoding.UTF8.GetString(strArr);
                             //strmContents = System.Text.Encoding.ASCII.GetString(strArr);
                             //strmContents = System.Text.Encoding.Default.GetString(strArr);
                             Dictionary<string, string> dir = JsonConvert.DeserializeObject<Dictionary<string, string>>(strmContents);
                             foreach (KeyValuePair<string, string> dv in dir)
                             {
                                 if (!has.ContainsKey(dv.Key))
                                 {
                                     has.Add(dv.Key, dv.Value);
                                 }
                             }
                         }
                         catch { }
                         #endregion
                        #region  
                         try
                         {
                             XmlDocument xmlDoc = new XmlDocument();
                             xmlDoc.Load(this.HttpContext.Request.InputStream);
                             XmlNode root = xmlDoc.SelectSingleNode("xml");
                             XmlNodeList xnl = root.ChildNodes;
                            foreach (XmlNode xnf in xnl)
                             {
                                 if (!has.ContainsKey(xnf.Name))
                                     has.Add(xnf.Name, xnf.InnerText);
                             }
                         }
                         catch { }
                         #endregion
                     }
                 }
                 catch (Exception ex)
                 {
}
#endregion
return Content("success");
}
  
转载:https://blog.csdn.net/wysdong/article/details/128331758