我正在开发一个项目,我正在使用视图的模板,我想在发布数据时从我的视图重定向到我的登录页面。我在@BeginForm(MVC)中获取值。重定向到“注册”页面的过程非常完美,但不是“登录”。 有人可以指导我吗?
The code for my View is
@model CDCReg.Models.RegistrationModel
@{
Layout = null;
}
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<!-- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Login and Registration Form with HTML5 and CSS3" />
<meta name="keywords" content="html5, css3, form, switch, animation, :target, pseudo-class" />
<meta name="author" content="Codrops" />
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="~/css/demo.css" />
<link rel="stylesheet" type="text/css" href="~/css/style.css" />
<link rel="stylesheet" type="text/css" href="~/css/animate-custom.css" />
<title>Register</title>
</head>
<body>
<div class="container">
<header>
<h1>Login Form <span></span></h1>
<nav class="codrops-demos">
<span><strong></strong> </span>
<h2>CDC Portal</h2>
</nav>
</header>
<section>
<div id="container_demo">
<a class="hiddenanchor" id="toregister"></a>
<a class="hiddenanchor" id="tologin"></a>
<div id="wrapper">
<div id="login" class="animate form">
<form action="mysuperscript.php" autocomplete="on">
@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>Log in Form</legend>
<ol>
<li>
@Html.LabelFor(m => m.MailId)
@Html.TextBoxFor(m => m.MailId)
@Html.ValidationMessageFor(m => m.MailId)
</li>
<li>
@Html.LabelFor(m => m.Password)
@Html.PasswordFor(m => m.Password)
@Html.ValidationMessageFor(m => m.Password)
</li>
<li>
@Html.CheckBoxFor(m => m.RememberMe)
@Html.LabelFor(m => m.RememberMe, new { @class = "checkbox" })
</li>
</ol>
<p class="signin button">
<input type="submit" value="Login" />
</p>
<p class="change_link">
Not a member yet ?
<a href="#toregister" class="to_register">Join us</a>
</p>
</fieldset>
}
</form>
</div>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<div id="register" class="animate form">
<form action="mysuperscript.php" autocomplete="on">
<h1> Sign up </h1>
<p>
<div class="editor-label">
@Html.LabelFor(model => model.Username)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Username)
@Html.ValidationMessageFor(model => model.Username)
</div>
</p>
<p>
<div class="editor-label">
@Html.LabelFor(model => model.FirstName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.FirstName)
@Html.ValidationMessageFor(model => model.FirstName)
</div>
</p>
<p>
<div class="editor-label">
@Html.LabelFor(model => model.LastName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.LastName)
@Html.ValidationMessageFor(model => model.LastName)
</div>
</p>
<p>
<div class="editor-label">
@Html.LabelFor(model => model.OrganisationName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.OrganisationName)
@Html.ValidationMessageFor(model => model.OrganisationName)
</div>
</p>
<p>
<div class="editor-label">
@Html.LabelFor(model => model.Role)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Role)
@Html.ValidationMessageFor(model => model.Role)
</div>
</p>
<p>
<div class="editor-label">
@Html.LabelFor(model => model.Location)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Location)
@Html.ValidationMessageFor(model => model.Location)
</div>
</p>
<p>
<div class="editor-label">
@Html.LabelFor(model => model.MailId)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.MailId)
@Html.ValidationMessageFor(model => model.MailId)
</div>
</p>
<p>
<div class="editor-label">
@Html.LabelFor(model => model.Password)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Password)
@Html.ValidationMessageFor(model => model.Password)
</div>
</p>
<p>
<div class="editor-label">
@Html.LabelFor(model => model.ConfirmPassword)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.ConfirmPassword)
@Html.ValidationMessageFor(model => model.ConfirmPassword)
</div>
</p>
<p>
</p>
<p class="signin button">
<input type="submit" value="Create" />
</p>
<p class="change_link">
Already a member ?
<a href="#tologin" class="to_register"> Go and log in </a>
</p>
</form>
</fieldset>
}
</div>
</div>
</div>
</section>
</div>
</body>
</html>