Reputation: 93
I am trying to implement a login page. The view loads and when the submit button is clicked the EmployeeID and Password is sent but the HttpPost method is not fired, even though the data is sent to the url.
The problem is the HttpPost method is not firing, I have tried placing a break point at yet it doesn't break.
Here is my View code:
@model Mike.Models.EMPLOYEE
....
<body style="background-color:white">
<img src="~/img/thrupps.png" style="width: 300px; height: 200px; margin: 0px 490px 0px 490px; " />
<div class="col-md-12">
<form class="login-form">
<div class="login-wrap">
@using (Html.BeginForm("Login", "Account", FormMethod.Post))
{
<p class="login-img"><i class="icon_lock_alt"></i></p>
<div class="input-group">
<span class="input-group-addon"><i class="icon_profile"></i></span>
@Html.TextBoxFor(a => a.EmployeeID, "EmployeeID", htmlAttributes: new { @class = "form-control" })
</div>
<div class="input-group">
<span class="input-group-addon"><i class="icon_key_alt"></i></span>
@Html.TextBoxFor(a => a.employee_password, "Password", htmlAttributes: new { @class = "form-control" })
</div>
<input type="submit" id="button" class="btn btn-lg btn-success btn-block " value="Login"/>
}
</div>
</form>
</div>
</body>
Here is the Controller code:
[AllowAnonymous]
public ActionResult Login(string returnUrl)
{
ViewBag.ReturnUrl = returnUrl;
return View();
}
//
// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(string returnUrl, string Password, int EmployeeID)
{
EMPLOYEE employee = new EMPLOYEE();
if (employee == null)
{
return View("Login","Account");
}
else
{
if(employee.employee_password.Equals(Password))
{
return View("Index", "Home");
}
else
{
return View("Login","Account");
}
}
}
Upvotes: 1
Views: 1053
Reputation:
You have nested forms which is invalid html and not supported. You need to remove the outer <form class="login-form">
tag.
Upvotes: 1