Controller
[ValidateAntiForgeryToken] [HttpPost] public ActionResult Index(FormCollection focm) { string name = focm["Name"]; ViewBag.Message = name; return View(); }
View
<div>欢迎 @ViewBag.Message 先生</div> @using (Html.BeginForm()) { @Html.AntiForgeryToken(); @Html.Label("姓名:") @Html.TextBox("name"); <input type="submit" value="确定" /> }
时间: 2024-10-14 05:08:02