使用c#函数时出现jquery ajax错误

使用c#函数时出现jquery ajax错误,c#,jquery,ajax,C#,Jquery,Ajax,我想在我的项目中使用jQueryAjax。我只是运行了一个简单的ajax,后面有代码。我得到的警报错误为“500内部错误” 对于aspx页面,您必须使用[WebMethod()]属性装饰代码隐藏方法: [WebMethod()] public static string sayHello() { return "hello "; } 编辑:WebMethod位于System.Web.Services.WebService命名空间中。您必须包含System.Web.Services.We

我想在我的项目中使用jQueryAjax。我只是运行了一个简单的ajax,后面有代码。我得到的警报错误为“500内部错误”


对于
aspx
页面,您必须使用
[WebMethod()]
属性装饰代码隐藏方法:

[WebMethod()]
public static string sayHello()
{
    return "hello ";
}

编辑:
WebMethod
位于
System.Web.Services.WebService
命名空间中。

您必须包含
System.Web.Services.WebService
命名空间。我也更新了我的答案。
 public static string sayHello()
    {
        return "hello ";
    }
[WebMethod()]
public static string sayHello()
{
    return "hello ";
}