在研究这个问题时,大多数SO问题都是关于该static方法作为修复.
因为它不使用真正的(有点复杂的)WebMethod我刚刚创建了一个简单的,以便检查是否可以达到方法本身.
[WebMethod]
[ScriptMethod(UseHttpGet = false)]
public static string HelloWorld()
{
return "Hello World!";
}
Run Code Online (Sandbox Code Playgroud)
电话.
<script>
$(document).ready(function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "usersWebMethods.aspx/HelloWorld",
dataType: "json",
success: function (data) {
alert(data.d);
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
它总是归结为 500 (Internal Server Error)
Unknown web method HelloWorld.
Parameter name: methodName
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it …Run Code Online (Sandbox Code Playgroud)