Can anyone spot the problem with this code?
View:
@model Tuple<LoginModel, RegisterModel>
<h2>Index</h2>
@using (Html.BeginForm("Login", "Login", FormMethod.Post))
{
@Html.TextBoxFor(tuple => tuple.Item1.User, new { @Name = "User" })
@Html.PasswordFor(tuple => tuple.Item1.Password, new { @Name = "Password" })
<button type="submit" name="Login">Connect</button>
}
@using .... Other actions.....
Controller:
[Authorize]
public class LoginController : Controller
{
//
// GET: /Login
[AllowAnonymous]
public ActionResult Index(string returnUrl)
{
return View();
}
//
// POST: /Login
[HttpPost]
[AllowAnonymous]
public ActionResult Login(LoginModel model, string returnUrl)
{
.
.
}
The Login method does not get called and I'm having a hard time finding out why. If I rename the action to Index, it gets called... Can anyone spot the problem here?
I appreciate any feed back.
Regards, Fábio
Edit: It seems this is a permission issue. Even though the Login method contains the AllowAnonymous attribute, it still is not allowed to be called. If I first perform the login and then try to trigger the action, it works. Now, How do I make sure this action is allowed by unauthenticated users? Tried both adding the path to root web.config file and adding a web.config file authorizing everyon on Login folder. None worked.
Thanks again for the help.