5
I own a controller in a Area
calling for "LoginProfessional
", with the actions Index, Logon, Logoff
. I make a RenderPage
calling for the Index
in Area
root of the project, but when I click on the button to send the form to the controller Home
of area LoginForm
he sends to the Home da Root
, this file is inside the directory of controllers of Login
, but rendered in Root
who owns a controller called Home
also. The code below:
Login Index (inside the Folder area LoginProfessional
):
@{
ViewBag.Title = "Login";
}
<div class="container row" style="width: 30%; margin-left: auto; margin-right: auto">
@using (Html.BeginForm("Logon", "Home", FormMethod.Post))
{
<form class="center-block form-signin" role="form" style="width: 30%; align-content: center">
<div class="form-group">
<input type="text" id="email" class="form-control" name="email" placeholder="E-mail" required="required" autocomplete="on">
<input type="password" id="password" class="form-control" name="password" placeholder="Senha" required="required" autocomplete="off">
<button class="btn btn-lg btn-primary btn-block" type="submit">Entrar</button>
<nav class="mainmenu pull-right" style="width: 246px; margin: auto; position: relative; max-width: 100%;">
<span class="pull-right">
<a class="btn btn-default btn-small" href="#registerProfessionalUser">Registrar</a>
</span>
</nav>
</div>
</form>
}
</div>
Location in _Layout.cshtml where you render this page at the root of the project (outside the areas):
<section class="section" id="professional">
<div class="container">
<h2 class="text-center title">Profissional</h2>
@RenderPage("~/Areas/LoginProfessional/Views/Home/Index.cshtml")
Correct controller within Loginprofessional area:
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Logon(FormCollection form)
{
if (ModelState.IsValid)
{
ProfessionalUser pUser = new ProfessionalUser();
using (LoginProfessionalDAO dao = new LoginProfessionalDAO())
{
pUser = dao.GetProfessionalUserByEmailAndPassword(form["email"].ToString(), form["password"].ToString());
}
if (pUser != null)
{
FormsAuthentication.SetAuthCookie(pUser.Name, false);
return Redirect("../../ProfessionalUser");
}
}
return RedirectToAction("Index", "Home");
}
public ActionResult Logoff()
{
FormsAuthentication.SignOut();
return RedirectToAction("Index", "Home");
}
}
I need to stop calling the Logon do Home
within the area LoginProfessional
, not the root, because it doesn’t even exist.