【发布时间】:2019-04-24 19:59:02
【问题描述】:
这是我的webmethod
[WebMethod]
public string CheckService(string name, ref string msg)
{
return "Hello" + name;
}
这是我的ajax 电话
$(document).ready(function () {
$.ajax({
type: "POST",
url: "<%= ResolveUrl("integrator.asmx/CheckService") %>",
data: '{name: "zakki",msg:"" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function (data1) {
console.log('', data1.d);
}
});
});
它会引发错误
Cannot convert object of type 'System.String' to type 'System.String&'
【问题讨论】:
-
WebMethod中的所有参数都必须使用传值,您不能为此使用ref(和out)关键字。 -
ref在你的方法中有什么意义?
标签: c# asp.net ajax web-services webforms