post接收数据(xml、json等)
Stream requestStream = System.Web.HttpContext.Current.Request.InputStream; byte[] requestByte = new byte[requestStream.Length]; requestStream.Read(requestByte, 0, (int)requestStream.Length); string requestStr = Encoding.UTF8.GetString(requestByte); if (!string.IsNullOrEmpty(requestStr)) { }
一般处理程序接收数据
context.Response.ContentType = "application/json"; context.Response.Cache.SetCacheability(HttpCacheability.NoCache); using (var reader = new System.IO.StreamReader(context.Request.InputStream)) { string jsonData = reader.ReadToEnd(); if (!string.IsNullOrEmpty(jsonData)) { try { } catch { } context.Response.Write("success"); } else { context.Response.Write("fail"); } }