我正在尝试将登录和注册表单放入相同的视图中.我在其他问题上做了所有建议,但我的问题仍然没有解决.
这是我的父视图authentication.cshtml:
@model Eriene.Mvc.Models.AccountVM
<div class="row">
<div class="col-md-6">
@Html.Partial("_Login", Model.Login ?? new Eriene.Mvc.Models.LoginVM())
</div>
<div class="col-md-6">
@Html.Partial("_Register", Model.Register ?? new Eriene.Mvc.Models.RegisterVM())
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在我的部分中,我使用这样的形式:
@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @id = "login-form", @role = "form", @class = "login-form cf-style-1" }))
Run Code Online (Sandbox Code Playgroud)
其中一个动作是这样的:
[HttpPost]
[AllowAnonymous]
public ActionResult Register(RegisterVM registerVM)
{
if (ModelState.IsValid)
{
User user = new Data.User();
user.Email = registerVM.Email;
user.ActivationCode = Guid.NewGuid().ToString();
user.FirstName = registerVM.FirstName;
user.LastName = registerVM.LastName;
user.Password = PasswordHelper.CreateHash(registerVM.Password);
return RedirectToAction("Index", "Home");
}
return View("Authentication", new …Run Code Online (Sandbox Code Playgroud)