using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Web;
using System.Text;
using System.Web.Script.Serialization;
// 接收 API 通过 Post 方式传送 Json格式的数据
public class GetIPN : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
string jsonText = string.Empty; context.Request.InputStream.Position = 0; //这一句很重要,不然一直是空
StreamReader sr = new StreamReader(context.Request.InputStream);
jsonText = sr.ReadToEnd();
// IPNinfo model = (new JavaScriptSerializer()).Deserialize(jsonText); //转化成实体对象
//然后去处理业务
context.Response.ContentType = "text/plain";
context.Response.Write("OK"); //API回调响应,如需要返回OK
}
public bool IsReusable
{
get
{
return false;
}
}
}
}