前台用ajax传值,如何处理数据,后台Dictionary<string, string> filters才能接收的到
frontend
$.post('/server',{key:"value","key2":"value2"})
backend controller
void post(dictionary<string,string> filters){
}
前台:
$.ajax({
url: "/Handler.ashx",
type: "post",
data: { "myDic": "{"key":"value"}" },
dataType: "json",
success: function (json) {
console.log(json);
},
error: function () { }
});
后台:
string sData = context.Request["myDic"] ?? string.Empty;
Dictionary<string, string> dicData = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(sData);
不行,会报错
如何改成这样,好像又变成了普通的string