我在CreateTicket.aspx.cs中有一个包含此方法的页面:
[WebMethod()]
public static string Categories()
{
var business = new CategoryBusiness();
var categories = business.ListRootCategories();
return categories.Json();
}
和页面上的javascript / jquery代码(同一页面,.aspx):
function LoadRootCategories() {
PageMethod("CreateTicket.aspx", "Categories", [], LoadCategoriesSucceded, LoadCategoriesFailed);
}
function PageMethod(page, fn, paramArray, successFn, errorFn)
{
//Create list of parameters in the form:
//{"paramName1":"paramValue1","paramName2":"paramValue2"}
var paramList = '';
if (paramArray.length > 0)
{
for (var i=0; i<paramArray.length; i+=2)
{
if (paramList.length > 0) paramList += ',';
paramList += '"' + paramArray[i] + '":"' + paramArray[i+1] + '"';
}
}
paramList = '{' + paramList + '}';
//Call the page method
$.ajax({
type: "POST",
url: page + "/" + fn,
contentType: "application/json; charset=utf-8",
data: paramList,
dataType: "json",
success: successFn,
error: errorFn
});
}
在firebug上运行它,我在控制台上收到以下错误:
500 Internal Server Error
UnkNown web method Categories.
[ArgumentException: UnkNown web method Categories.
Parameter name: methodName]
System.Web.Script.Services.WebServiceData.getmethodData(String methodName) +517489
System.Web.Handlers.ScriptModule.OnPostAcquireRequestState(Object sender, EventArgs eventArgs) +168
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
为什么会这样?
@R_404_5620@:
我解决了这个问题.
发生了什么事?有点蠢(像往常一样):
> CreateTicket.aspx页面声明中缺少“Inherits”属性,因此CreateTicket.aspx.cs未绑定为分部类,即使使用CodeBehind属性也是如此.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。