對於PaymentDetail,您可以在視圖使用:
@using(Html.BeginForm("PAymentDetail","Quote",FormMethod.Post))
{
//Form element here
}
結果HTML將
<form action="/Quote/PAymentDetail" method="post"></form>
同爲顧客詳細
@using(Html.BeginForm("CustomerDetail","Quote",FormMethod.Post))
{
//Form element here
}
希望有所幫助。只要這些方法具有不同的名稱,在同一個控制器中使用兩種post方法並不是問題。
對於除FormCollection以外的更好的方法,我推薦這個。 首先,創建一個模型。
public class LoginModel
{
public string UserName { get; set; }
public string Password { get; set; }
public bool RememberMe { get; set; }
public string ReturnUrl { get; set; }
}
然後,在視圖中:
@model LoginModel
@using (Html.BeginForm()) {
<fieldset>
<div class="editor-label">
@Html.LabelFor(model => model.UserName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.UserName)
//Insted of razor tag, you can create your own input, it must have the same name as the model property like below.
<input type="text" name="Username" id="Username"/>
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Password)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Password)
</div>
<div class="editor-label">
@Html.CheckBoxFor(m => m.RememberMe)
</div>
</fieldset>
}
這些用戶輸入將被映射到控制器中。
[HttpPost]
public ActionResult Login(LoginModel model)
{
String username = model.Username;
//Other thing
}
祝你好運。
您可能想要檢查您的路由配置,特別是如果您已將其從默認設置修改。 – MushinNoShin