我有一個接受一個參數的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