asp.net处理json数据

客户端

1
2
3
4
5
6
7
8
9
10
11
12
$('#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);
        }
    });
});

  

服务端:

1
2
3
4
5
6
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();

  

posted @ 2015-11-11 15:30  博斯芮网络科技  阅读(451)  评论(0编辑  收藏  举报