ASP.NET 后台获取backbone提交的数据

前端代码


后台代码

public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            
            // 获取前端提交的json字符串
            var strJson = new System.IO.StreamReader(context.Request.InputStream).ReadToEnd();  
          
            // 将json反序列化到Stu
            JavaScriptSerializer js = new JavaScriptSerializer();
            Stu sn = js.Deserialize(strJson);  

            context.Response.Write(sn.Name);
        }

        public class Stu
        {
            public int ID
            {
                set;
                get;
            }

            public string Code
            {
                set;
                get;
            }

            public string Name
            {
                set;
                get;
            }
        }


你可能感兴趣的:(Backbone.js,ASP.NET,C#)