GET 透過 QueryString 傳值,資料可見;POST 透過 Request Body 傳值,支援大量資料(如檔案上傳)且較安全(如登入)。
public class Account {
public string UserName { get; set; }
public string Password { get; set; }
}
<form method="post" action="/Account/Login">...</form>$.post("/Account/Login", { UserName: "a", Password: "b" }, callback);/Account/Login?UserName=a&Password=bController 以 ActionResult Login(Account account) 直接繫結模型,或使用 Request.Form 手動取值。輔助驗證方法 AreEquals 示範簡單邏輯判斷。