我有一个接受一个参数的WebMethod。WebMethod(有时)返回整个网站
当我发送一个没有任何参数的webmethod的请求时,一切正常,但是当我给同一个方法提供一个参数时,它返回整个站点而不是字符串。
页面参数除列表的内容外没有任何变化。
列表只是ListView,它显示字符串列表。
当我使用URLRewriting时,URL在实例中是不同的,我从实例中提供参数的时候,我不这样做。
任何人都可以帮助我解决这个问题吗?
我的WebMethod:
[WebMethod]
public static string GetResult(int id)
{
return "Hooray";
}
我的网站的方法调用:
PageMethods.GetResult(docId,
function onSuccess(list) {
$(element).parent().siblings().filter(":first").append(list);
});
URL不带参数:
www.mywebsite.com/items is rewritten to www.mywebsite.com/items.aspx
URL与参数:
www.mywebsite.com/items/1 is rewritten to www.mywebsite.com/items.aspx?id=1
非常感谢!有效。我唯一需要添加到解决方案的是添加根网址。我使用'var url = window.location.href; var baseUrl = url.substring(0,url.indexOf('/',24)); PageMethods.set_path(baseUrl +'/item.aspx');' – JNM