Copied to clipboard

Flag this post as spam?

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


  • Simon Yohannes 58 posts 188 karma points
    Aug 16, 2018 @ 21:51
    Simon Yohannes
    0

    Members.Login() method error

    using Members.Login method to login members (in a surface controller) produces the following error

    System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
    Parameter name: length
    

    it seems to depend on the username passed through. if i enter [email protected] it works but [email protected] doesn't. the password i'm using is Password1! if it helps reproduce the error.

    any way to avoid this? thanks

  • Nik 1517 posts 6705 karma points MVP 5x c-trib
    Aug 17, 2018 @ 14:35
    Nik
    0

    Hi Simon,

    Can you show a bit more of your code that is running to do this login? Also, sorry if it's an obvious question, have you double checked that there are members configured with both of those two e-mail addresses?

    Thanks,

    Nik

  • Simon Yohannes 58 posts 188 karma points
    Aug 18, 2018 @ 18:59
    Simon Yohannes
    0

    yes the user is registered and exists. the code is as follows

    public ActionResult Login(LoginModel model) {
                if (!ModelState.IsValid)
                    return CurrentUmbracoPage();
    
                if (Members.Login(model.Username, model.Password))
                    return Redirect("/");
    
                ModelState.AddModelError("", "Invalid login");
    
                return CurrentUmbracoPage();
            }
    
Please Sign in or register to post replies

Write your reply to:

Draft