I'm using a bootstrap login/Registration form and I had to make some changes to my code since it is all happening in one view, so first I had two separated models LoginViewModel and RegisterViewModel, I created another view model called it loginRegisterViewModel
public class LoginRegisterViewModel
{
public LoginViewModel LoginViewModel { get; set; }
public RegisterViewModel RegisterViewModel { get; set; }
}
this is part of my View
@using Saff.Models
@model LoginRegisterViewModel
@{
ViewBag.Title = "Log in";
}
@using (Html.BeginForm("Login", "Account", new { ReturnUrl =
ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-
horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<div class="body-content">
<div class="container">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="row">
<div class="col-md-6">
<div class="panel with-nav-tabs panel-info">
<div class="panel-heading">
<ul class="nav nav-tabs">
<li class="active"><a href="#login" data-toggle="tab"> Login </a></li>
<li><a href="#signup" data-toggle="tab"> Signup </a></li>
</ul>
</div>
<div class="panel-body">
<div class="tab-content">
<div id="login" class="tab-pane fade in active register">
<div class="container-fluid">
<div class="row">
<h2 class="text-center" style="color: #5cb85c;"> <strong> Login </strong></h2><hr />
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<span class="glyphicon glyphicon-user"></span>
</div>
<div class="form-group">
@Html.LabelFor(m => m.LoginViewModel.Email, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.LoginViewModel.Email, new { @class = "form-control" })
</div>
</div>
</div>
</div>
</div>
</div>
..............
this is the login and register action methods
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginRegisterViewModel model, string returnUrl)
{
if (!ModelState.IsValid)
{
return View(model);
}
.......//more code here
}
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Register(LoginRegisterViewModel model)
{
if (ModelState.IsValid)
{
.....//more code here
}
as you can see I changed the models in both of them
So my question is how can I connect the register and login methods to the same view, the login is already connected since it is the one I modified, still when I press the login submit button it is not actually working and I don't go any where. does it have to do with me changing the name of the model in the controller? I don't know, but I need some help here