ASP.NET jQuery错误:未知的Web方法

这是我第一次尝试从jQuery调用ASP.NET页面方法。 我收到状态500错误的responseText消息,无法找到Web方法。 这是我的jQuery $ .ajax调用:

function callCancelPlan(activePlanId, ntLogin) { var paramList = '{"activePlanId":"' + activePlanId + '","ntLogin":"' + ntLogin + '"}'; $.ajax({ type: "POST", url: "ArpWorkItem.aspx/CancelPlan", data: paramList, contentType: "application/json; charset=utf-8", dataType: "json", success: function() { alert("success"); }, error: function(xml,textStatus,errorThrown) { alert(xml.status + "||" + xml.responseText); } }); } 

这是我试图调用的页面方法:

 [WebMethod()] private static void CancelPlan(int activePlanId, string ntLogin) { StrategyRetrievalPresenter presenter = new StrategyRetrievalPresenter(); presenter.CancelExistingPlan(offer, ntLogin); } 

我通过使用和不使用parens’()’来装饰Web方法来尝试这个。 有人有想法吗?

您的Web方法需要公开且静态。

清理解决方案并重建。 我见过webmethods抛出500’s直到你这样做。

在方法之前添加public static

恩。

 [WebMethod] public static string MethodName() {}