【发布时间】:2021-04-01 19:27:45
【问题描述】:
我收到以下错误
System.InvalidOperationException: CheckPageAccess Web 服务方法名称无效。 在 System.Web.Services.Protocols.HttpServerProtocol.Initialize() 在 System.Web.Services.Protocols.ServerProtocolFactory.Create(类型类型,HttpContext 上下文,HttpRequest 请求,HttpResponse 响应,Boolean& abortProcessing)
我的网络方法
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public void CheckPageAccess(string userid, Pages PageNo, bool IsPresentApprover = false)
{
Ajax 请求
this.CheckPageAccess = function (UserID) {
var response = $http({
url: "WebServicenName.asmx/CheckPageAccess",
dataType: 'json',
params: { 'userid': UserID, 'PageNo': PageNo, 'IsPresentApprover': IsPresentApprover},
contentType: 'application/json;charset=utf-8',
method: 'GET',
async: true,
cache: false,
headers: { 'Accept': 'application/json', 'Pragma': 'no-cache' },
});
return response;
}
这在调试模式下工作正常,但是当我发布上面的 web 方法时不会显示在托管链接中。
【问题讨论】:
-
不要粘贴错误图片。
-
听起来好像没有上传文件,App_Code 文件夹中的 .asmx 或 .cs 文件。上面的名字改了吗?如果你没有,看起来像一个错字。 (
WebServicenName中的 2 个 n。) -
$http有效吗?尝试使用$.ajax({...。