I have a Logon page in a MVC (1.0) application that I am securing with SSL, I have an attribute that inspects the request for the page and redirects to a https uri when it is requested with http. This all works, however when I post the form content i get the following error:
The parameters dictionary contains a null entry for parameter 'rememberMe' of non-nullable type 'System.Boolean' for method 'System.Web.Mvc.ActionResult LogOn(System.String, System.String, Boolean, System.String)' in 'DAC.US.Web.Portal.Controllers.AccountController'. To make a parameter optional its type should be either a reference type or a Nullable type. Parameter name: parameters
here is the controller code...
//
// GET: /Account/LogOn
[RequiresSSL]
public ActionResult LogOn(string ReturnUrl)
{
if (TempData["Message"] != null)
ViewData["Message"] = TempData["Message"];
TempData["Message"] = null;
ViewData["ReturnUrl"] = ReturnUrl ?? "/Home";
return View();
}
Again, the RequireSSL Attribute works, but the POST from that SSL uri does not. What is not working?
Here is the Action (POST) Method, I apologize for not posting. This all works file when not running as SSL, but when i change to run under SSL the POST's do not work anymore.
//
// POST: /Account/LogOn
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl)
{
Logger.InfoFormat("LogOn : ({0}, PASSWORD, {1}, {2}).", userName, rememberMe, returnUrl);
if (!ValidateLogOn(userName, password))
{
return View();
}
_FormsAuthentication.SignIn(userName, rememberMe);
if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(this.Request.Url.AbsoluteUri.Replace(this.Request.RawUrl, returnUrl).Replace("https://", "http://"));
}
else
{
return Redirect(this.Request.Url.AbsoluteUri.Replace(this.Request.RawUrl, "/Home").Replace("https://", "http://"));
//return RedirectToAction("Index", "Home");
}
}
Form HTML
<% using (Html.BeginLogOnForm()){ %>
<div class="logon-row logon-sso-row">
<div class="logon-links-row"><a href="<%=Url.Action("SingleSignOn", "Account", new{ReturnUrl=ViewData["ReturnUrl"]}) %>">Single Sign On</a></div>
</div>
<div class="logon-row">
<span class="block-span logon-label-cell">User Name:</span>
<span class="block-span"><%= Html.TextBox("username", null, new { style = "width:150px" })%></span>
</div>
<div class="logon-row">
<span class="block-span logon-label-cell">Password:</span>
<span class="block-span"><%= Html.Password("password", null, new { style="width:150px" })%></span>
</div>
<div class="logon-row">
<span class="block-span logon-label-cell">Remember Me?:</span>
<span class="block-span"><%= Html.CheckBox("rememberMe")%></span>
</div>
<div class="logon-row logon-bottons-row">
<input type="submit" value="Log On" class="mainshipButton mainshipPageButton" />
</div>
<div class="logon-row">
<div class="logon-links-row"><a href="<%=Url.Action("Request", "Account") %>">Request Account</a></div>
<div class="logon-links-row"><a href="<%=Url.Action("Forgot", "Account") %>">Forgot ID/Password</a></div>
</div>
<% } %>