我將模型切回了一個(gè)領(lǐng)域://模型public class LetterViewModel{ public string LetterText;}//控制器public ActionResult Index(){ var model = new LetterViewModel(); model.LetterText = "Anything"; return View(model);}[HttpPost]public ActionResult Index(LetterViewModel model){ //model.LetterText == null return View(model);}//視圖@model Test.Models.LetterViewModel@{ Layout = "~/Views/Shared/_Layout.cshtml"; ViewBag.Title = "Create a Letter";}@using (Html.BeginForm()){ <div id="Bottom"> @Html.TextAreaFor(m => m.LetterText) <input type="submit" value="Ok" class="btn btn-default" /> </div>}當(dāng)我在開發(fā)工具中檢查“網(wǎng)絡(luò)”選項(xiàng)卡時(shí),它顯示輸入的值已包含在請(qǐng)求中。但是,當(dāng)HttpPost控制器被激發(fā)時(shí),該字段為空。
當(dāng)我發(fā)回到控制器時(shí),模型的所有值都為空
翻翻過去那場(chǎng)雪
2019-12-06 11:03:41