我遇到了这个问题,我在不同的 cshtml 文件中有一个登录屏幕和一个注册屏幕,但注册视图被称为 @Html.Partial。登录屏幕中的代码如下:
<div class="panelLogIn left @if (ViewBag.register) { Write("hidden"); }">
@using (Html.BeginForm()) {
<div>
<div class="validationMessage" style="padding-bottom:10px;">@Html.ValidationMessage("loginFailed")</div>
<div class="field">
<span class="textOverField absolute em1-2" style="top:6px;left:4px;">User</span>
@Html.TextBoxFor(a => a.UserName, new { @class = "textField" }) <div class="absolute validationMessage">@Html.ValidationMessageFor(u => u.UserName)</div>
</div>
<div class="field relative">
<span class="textOverField absolute em1-2" style="top:6px;left:4px;">Password</span>
@Html.PasswordFor(a => a.Password, new { @class = "textField" }) <div class="absolute validationMessage">@Html.ValidationMessageFor(u => u.Password)</div>
</div>
<div class="em0-9" style="margin-bottom: 20px;">
<input class="submitButton cursorHand" style="margin-top: 10px;" type="submit" value="Enter" />
</div>
<div class="em0-9">
<span class="guestLink bold linkBlue underline cursorHand">Register Free</span>
</div>
</div>
}
</div>
<div class="panelGuest left @if (!ViewBag.register) { Write("hidden"); }">
@Html.Partial("RegisterUser", Model.NewUser)
</div>
注册视图如下:
@using (Html.BeginForm("Register", "Account"))
{
/* The text boxes and form elements */
<div class="em0-9" style="margin-bottom:20px;">
<input class="submitButton cursorHand" style="margin-top:10px;" type="submit" value="Register" />
</div>
}
基本上,问题是当我尝试注册新用户时,它会将我重定向到 localhost/Account/Register,当我返回登录屏幕(在同一视图中)时,我无法调用任何其他操作从寄存器一。
对此的任何帮助将不胜感激。