hi,
view:
- @using (Html.BeginForm())
- {
- @Html.ValidationSummary(true, "Login Failed, check details");
- <div>
- <br />
- <fieldset>
- <legend>Login Formlegend>
- <div class="editor-label">@Html.LabelFor(u => u.UserName)div>
- <div class="editor-field">
- @Html.TextBoxFor(u => u.UserName)
- @Html.ValidationMessageFor(u => u.UserName)
- div>
- <div class="editor-label">@Html.LabelFor(u => u.Password)div>
- <div class="editor-field">
- @Html.PasswordFor(u => u.Password)
- @Html.ValidationMessageFor(u => u.Password)
- div>
- <br />
- <input type="submit" value="Log In" />
- <button class="btn btn-lg btn-success btn-block" type="submit">@Html.ActionLink("Login", "Login", "Home", new { /* ID TO BE PASSED*/ }, null)button>
- fieldset>
- div>
- }
- public ActionResult Index()
- {
- return View();
- }
- [ChildActionOnly]
- public ActionResult Login()
- {
- return PartialView("_Login");
- }
- [HttpPost]
- //[ValidateAntiForgeryToken]
- public ActionResult Login(Models.Account objUser)
- {
- if (ModelState.IsValid)
- {
- using (MyDatabaseEntities db = new MyDatabaseEntities())
- {
- var obj = db.Accounts.Where(a => a.UserName.Equals(objUser.UserName) && a.Password.Equals(objUser.Password)).FirstOrDefault();
- if (obj != null)
- {
- Session["UserName"] = obj.UserName.ToString();
- Session["IsAdmin"] = obj.IsAdmin.ToString();
- return RedirectToAction("Index", "Account");
- }
- }
- }
- // return View("Dashboard/Index");
- return View(objUser);
- }
i want login controller to be executed whn login is clicked. please suggest what id is to be passed from the view to execute public ActionResult Login(Models.Account objUser) controller.

Saineshwar BageriRank #115 · 19.6K reputationPosted Apr 19, 2017, 9:48 PM EDT
Ramesh PalanivelRank #372 · 6.8K reputationPosted Apr 19, 2017, 9:56 PM EDT
Chandrakant Verma32 reputationPosted Apr 19, 2017, 9:58 PM EDT
Chandrakant Verma32 reputationPosted Apr 19, 2017, 9:59 PM EDT
Saineshwar BageriRank #115 · 19.6K reputationPosted Apr 19, 2017, 10:39 PM EDT
@Html.ValidationSummary(true, "Login Failed, check details");
public ActionResult Login()
{
return View();
}
[HttpPost]
public ActionResult Login(Model value)
{
return View();
}
Ramesh PalanivelRank #372 · 6.8K reputationPosted Apr 19, 2017, 10:53 PM EDT