对于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