在我的ASP MVC Web应用程序中。我有这个控制器
namespace Test.Controllers
{
public class HomeController : Controller
{
// GET: Home
public ActionResult Index(UserDetails user)
{
user.UserEmail = "Email one";
return View(user);
}
// Post: Home
[HttpPost]
public ActionResult Index(UserDetails user, string command)
{
user.UserEmail = "Email two";
return View(user);
}
#region Helpers
#endregion
}
}
和这个观点
@model Test.Models.UserDetails
@{ Layout = null;}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
@Html.DisplayNameFor(model => model.UserEmail)
@Html.EditorFor(model => model.UserEmail)
<input type="submit" name="Command" value="Search" class="btn btn-default" />
A}
</body>
</html>
当我第一次运行应用程序时,它会在文本框中显示“Email one”。但是,当我点击提交按钮时,它不会将文本框中的值更改为“电子邮件二”。我的代码需要改变什么?