I am currently working on an ASP.NET MVC3 website.
I have a simple authentication form, binded on a simple viewmodel. When debugging on local, everything works fine.
But the website has to wotk on Apache + monomod too. And here is the strange behavior I encounter: the same form, with the same requests and parameters, are nto working.
More details:
The viewmodel:
/// <summary>
/// Form authentication info
/// </summary>
public class LogOnModel
{
/// <summary>
///
/// </summary>
[DisplayName("Username")]
public string UserName { get; set; }
/// <summary>
///
/// </summary>
[DisplayName("Password")]
public string Password { get; set; }
/// <summary>
///
/// </summary>
[DisplayName("Remember me?")]
public bool RememberMe { get; set; }
/// <summary>
/// Targeted URL
/// </summary>
public string Target { get; set; }
/// <summary>
///
/// </summary>
public LogOnModel()
{
}
}
The main part of the view, page where the user can enter its username and password :
<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<Website.Areas.Public.Models.LogOnModel>" %>
<p>
Please enter your username and password to continue.
</p>
<% using (Html.BeginForm())
{ %>
<%= Html.ValidationSummary(true, "Authentication failed.")%>
<p>
<%= Html.ActionLink("I forgot my password","PasswordRecovery","Home") %>
</p>
<div>
<fieldset>
<div class="editor-label">
<%= Html.LabelFor(m => m.UserName) %>
</div>
<div class="editor-field">
<%= Html.TextBoxFor(m => m.UserName) %>
<%= Html.ValidationMessageFor(m => m.UserName)%>
</div>
<div class="editor-label">
<%= Html.LabelFor(m => m.Password)%>
</div>
<div class="editor-field">
<%= Html.PasswordFor(m => m.Password) %>
<%= Html.ValidationMessageFor(m => m.Password) %>
</div>
<div class="editor-field">
<%= Html.CheckBoxFor(m => m.RememberMe) %>
Remember me
</div>
<p>
<input type="submit" value="Connect me!" />
</p>
</fieldset>
</div>
<% } %>
And the controller, receiving the auth infos :
[HttpPost]
public ActionResult LogOn(LogOnModel model)
{
string username = model.UserName;
string password = model.Password;
//On Apache, username & password are empty
...
}
As I say in the comments, username & password are empty. Everything is working fine on a local ASP.NET debug server, and using Fiddler I can see that the requests for authentication contains form data (username, password, etc).
Any idea why the binding seems not to be working?
Thanks.
Just found my answer, many months later. It’s a bit late but if anyone has the same problem, here’s the solution :
Clean the Web.config file. Delete every lines that are optionnals