1. 程式人生 > >.net 一般處理程序接收集合

.net 一般處理程序接收集合

plain new NPU world ont stream odi script put

1.後端代碼

 public class Handler1 : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {

            context.Response.ContentType = "application/json";
            context.Response.ContentEncoding = Encoding.UTF8;

            Stream inputStream = context.Request.InputStream;
            Encoding encoding 
= context.Request.ContentEncoding; StreamReader streamReader = new StreamReader(inputStream, encoding); string strJson = streamReader.ReadToEnd(); JavaScriptSerializer json = new JavaScriptSerializer(); var test = json.Deserialize<List<TestClass>>(strJson); context.Response.ContentType
= "text/plain"; context.Response.Write("Hello World"); } public bool IsReusable { get { return false; } } } public class TestClass { public string Name { get; set; }
public int Age { get; set; } }

2.前端代碼

         var array2= [{ name:"a", age: 1 }, { name:"b", age: 2 }, { name:"c", age: 3}]
         var data = JSON.stringify(array2);
         $.post("Handler1.ashx", data, function () {
          });

.net 一般處理程序接收集合