asp.net处理json数据

客户端

            $('#createAuth').click(function () {
                var jsonObj = { id:0, name:'权限' + new Date() }
                $.ajax({
                    type: 'post',
                    url: 'service/authority/create.ashx',
                    data: JSON.stringify(jsonObj),
                    dataType: 'json',
                    success: function (d) {
                        alert(d.Text);
                    }
                });
            });

  

服务端:

            context.Response.ContentType = "application/json";
            context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            var request = context.Request.InputStream;
            StreamReader sr = new StreamReader(request);
            string json = HttpUtility.UrlDecode(sr.ReadToEnd());
            sr.Close();

  

你可能感兴趣的:(asp.net处理json数据)