Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • glenatron 37 posts 132 karma points
    Mar 06, 2014 @ 13:11
    glenatron
    0

    Log-in form works in one place, doesn't work in another in 6.1.6

    I have a Log-in form that passes a model to a SurfaceController for validation.

    The form works correctly and looks like this:

       using (Html.BeginUmbracoForm("Login", "LoginSurface"))
        {
           @Html.EditorFor(x => Model)
           <input type="submit" />
        }
    

    However, I have a smaller log-in form in my other pages, which looks like this:

        @using (Html.BeginUmbracoForm("Login", "LoginSurface"))
        {
            @Html.TextBoxFor(x => login.Name, new { placeholder="username" }) <br />
            @Html.TextBoxFor(x => login.Password, new { placeholder = "password" }) <br />
            <input type="submit"  value="Sign In" class="button">
        }
    

    The design dictates that this look a little different, but I can't see that it should behave differently.

    The SurfaceController that collects these requests looks like this:

        [HttpPost]
        [ActionName("Login")]
        public ActionResult LoginPost(LoginModel model)
        {
            if (Membership.ValidateUser(model.Username, model.Password))
            {
                FormsAuthentication.SetAuthCookie(model.Username, model.Remember);
                return RedirectToCurrentUmbracoPage();
    
            }
            else
            {
                TempData["Status"] = "Invalid username or password";
                return RedirectToCurrentUmbracoPage();
            }
        }
    

    The problem is that when my second form is used, the LoginModel is coming back to the SurfaceController with all it's fields empty.

    Any idea what is going on?

  • Peter Bailey 6 posts 27 karma points
    Mar 07, 2014 @ 21:36
    Peter Bailey
    0

    In your smaller form, your field names and your x=>login don't seem to match the model. Also, for password fields you should use @Html.PasswordFor 

Please Sign in or register to post replies

Write your reply to:

Draft