控制器告诉视图它需要的一切,视图显示它。视图不知道控制器。
@using (Html.BeginForm("Login", "Account", FormMethod.Post, new { @class = "form-signin", ReturnUrl = ViewBag.ReturnUrl }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<h2 class="form-signin-heading">Please sign in</h2>
<br />
@Html.TextBoxFor(m => m.UserName, new { @class = "input", type = "text", placeholder = "Username" })
<br />
@Html.PasswordFor(m => m.Password, new { @class = "input", type = "password", placeholder = "Password" });
<br /><br />
<button type="submit">Sign in</button>
}
在该登录表单中,控制器上方法的链接是(“Login”,“Account”),其中“Login”是方法名称,“Account”是控制器名称。