未知的网络方法.参数名称:methodName

 张炜26_807 发布于 2023-02-08 15:55

在研究这个问题时,大多数SO问题都是关于该static方法作为修复.

因为它不使用真正的(有点复杂的)WebMethod我刚刚创建了一个简单的,以便检查是否可以达到方法本身.

[WebMethod]
[ScriptMethod(UseHttpGet = false)]
public static string HelloWorld()
{
    return "Hello World!";
}

电话.


它总是归结为 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 originated in the code. 
Exception Details: System.ArgumentException: Unknown web method HelloWorld.
Parameter name: methodName

为什么这会失败?

2 个回答
  • 我也有这个问题,但稍微不同的是我在.asmx文件中使用了这个方法,因此遇到了"静态"问题,但是以不同的方式.

    如果你有一个方法作为你的Page类的一部分,它必须static.

    如果你已经把一个方法的.asmx文件跨页使用,它不能static.

    2023-02-08 15:59 回答
  • 我在实际的.aspx文件中遇到了问题

    <%@ Page Language="C#" 
             AutoEventWireup="true" 
             CodeBehind="xxx.xxx.cs" Inherits="xxx.xxx" %>
    

    代码中没有出现.它是如何改变的?我不知道 :(.

    2023-02-08 15:59 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有