ajax中如何通过post或get方法发送数据到后台,后台通过Request获取数据并添加到NameValueCollection中

实体类如下:

  public class Peson
    {
        public string Name { get; set; }
        public string Sex { get; set; }
    }

前台通过Jquery的中post或get方法发送数据到后台,格式:{"Name":"张三","Sex":"男"} 

后台通过Request获取数据并添加到NameValueCollection中;
NameValueCollection paramValueCollection = new NameValueCollection();
paramValueCollection.Add(context.Request.QueryString);
paramValueCollection.Add(context.Request.Form);

取值:paramValueCollection ["Name"]

猜你喜欢

转载自blog.csdn.net/shan1774965666/article/details/105987444