直接上代码:
public void ProcessRequest(HttpContext context)
{
int flag = 0;
string msg = "调用成功";
string result = "";
context.Response.AddHeader("Access-Control-Allow-Origin", "*");//允许跨域访问
context.Response.ContentEncoding = Encoding.UTF8;
context.Response.ContentType = "application/json";// 三种设置测试都通过,不设置contenType也可以 "application/json" "text/plain" "text/json"
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
using (var reader = new System.IO.StreamReader(context.Request.InputStream))
{
String xmlData = reader.ReadToEnd();//得到POST过来数据
if (!string.IsNullOrEmpty(xmlData))
{