public ActionResult notify()//NameValueCollection Form, NameValueCollection Params, HttpRequestBase Request
{
//facePay/notify
string _param = "", _form = "";
var _jsonData = string.Empty;
try
{
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];
has.Add(k, v);
}
_form = JsonConvert.SerializeObject(has);
}
has = new Hashtable();
collection = this.HttpContext.Request.QueryString;
foreach (string k in collection)
{
string v = (string)collection[k];
has.Add(k, v);
}
_param = JsonConvert.SerializeObject(has);
//_jsonData = JsonConvert.SerializeObject(has);
if (this.HttpContext.Request.InputStream.Length > 0)
{
byte[] requestData = new byte[Request.InputStream.Length];
Request.InputStream.Position = 0;
Request.InputStream.Read(requestData, 0, (int)Request.InputStream.Length);
_jsonData = System.Text.Encoding.UTF8.GetString(requestData);
_jsonData = System.Web.HttpUtility.UrlDecode(_jsonData, System.Text.Encoding.UTF8).Trim();
writeLog("收到的通知Request_JOSN:" + _jsonData);
//XmlDocument xmlDoc = new XmlDocument();
//xmlDoc.Load(this.HttpContext.Request.InputStream);
//XmlNode root = xmlDoc.SelectSingleNode("xml");
//XmlNodeList xnl = root.ChildNodes;
//foreach (XmlNode xnf in xnl)
//{
// has.Add(xnf.Name, xnf.InnerText);
//}
}
}
catch (Exception ex)
{
writeLog("notify出错:" + ex.Message);
}
return this.Json(new { form = _form, param = _param, json = _jsonData }, JsonRequestBehavior.AllowGet);
}