1
我有以下模型。獲取額外的輸入名稱不在模型類別中
public class M
{
public int A { get; set; }
public int B { get; set; }
}
而且我有以下剃刀視圖。
@model MyApp.Models.M
@using (Html.BEginForm("Create", "Test", new { id = ...}, FormMethod.Post)) {
@Html.EditorFor(m => m.A)
@Html.EditorFor(m => m.B)
<input name="C">
}
控制器方法,
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(Guid id, M m)
{
// How to get C?
}
如何獲得輸入C在控制器中的值? (一個解決方案可能是創建一個額外的視圖模型並將其映射模型,有沒有簡單的方法?)
這是正確的嗎? '公共ActionResult創建(Guid id,M m,字符串C)'? – ca9163d9
如果你想要,你也可以這樣做。 –