WebApi+Ajax传参与接收
展开
1、Post请求不同类型
///////===========dynamic
$.ajax({
url: "api/Launch/Data",
type: "post",
data: JSON.stringify({ xml: xmlstr }),
contentType:"application/json",
dataType: "text",
async: false,
success: function (xml){}
});
public string Data(dynamic xml)
{
return "这是xml类型的参数";
}
///////===========JObject
public string Data(JObject xml)
{
}
$.ajax({
url: "api/Launch/Data",
type: "post",
data: { xml: xmlstr },
dataType: "text",
async: false,
success: function (xml){}
});
//======================
$.ajax({
url: "api/Launch",
type: "post",
data:{"":"22"},
dataType: "text",
async: false,
success: function (xml) {
}});
public string Post([FromBody]string xml)
{
}
============================
public string Post([FromBody]string xml)
{
}
$.ajax({
url: "api/Launch",
type: "post",
data:"=sss",
dataType: "text",
async: false,
success: function (xml) {}
});
2、多个Post请求可以webAPi配置文件里面加个action
————————————————
版权声明:本文为CSDN博主「放开那段代码让我来」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u014424282/article/details/96505524