我在一個頁面上工作,我有一個公司產品列表,並且我已經創建了用於排序和搜索產品的按鈕。
我的操作方法是這樣的:
public async Task<ActionResult> CustomerProducts(ActivityViewModel activityModel) {
// fetch products using web api and return partial view
}
我寫了ActivityViewModel
public class ActivityViewModel {
public string customerId { get; set; }
public int skip { get; set; }
public int noOfRecords { get; set; }
public DateTime? startDate { get; set; }
public DateTime? endDate { get; set; }
public string sortOrder { get; set; }
public string searchText { get; set; }
public string searchField { get; set; }
public int? searchProductId { get; set; }
}
現在我的問題是,當特定產品的用戶搜索或對其進行排序,應該調用到服務器是jQuery $ .get或$ .post?
我知道傳統得到和後請求的區別。如果我堅持這條規則,服務器端沒有任何變化,這個請求當然可以被緩存。在這種情況下,請求應該得到。但它是我困惑的ajax場景。模型綁定在這種情況下如何工作?如果我使用ajax獲得此目的,模型綁定器會綁定這些值嗎?這種情況的首選方式是什麼?
在此先感謝。
是的,你是對的。我嘗試使用GET,但一旦參數不再爲空,一些URL數據就開始丟失。沒有更好的方法嗎?在不違反W3C的建議(使用GET而不是POST來獲取)?如果我想緩存記錄怎麼辦? – Aneeq