The input is not a valid Base-64 string because it contains an ASP.NET identifier that is not based on 64 characters

I use the asp.net id for login and authentication. I get an error for a password field when logging in with the following method.

model = custom object

var user = await UserManager.FindAsync(model.UserName, model.Password); if (user != null) { bool isPersistent = false; await SignInAsync(user, isPersistent); return RedirectToLocal(returnUrl); } 

Input is not a valid Base-64 string because it contains a non-base 64 character, more than two indentation, or an invalid character among padding characters

+6
source share
1 answer

Do you use EF? If so, you should not add AspNetRoles, AspNetUserClaims, AspNetUserLogins, and AspNetUserRoles to your edmx.

In addition, I always use the Login method, as shown below. If I need to save some information (e.g. userRole, userName, etc.), I use Session as shown below.

 public async Task<ActionResult> Login(LoginViewModel model) { if (!ModelState.IsValid) { return View(model); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var user = await UserManager.FindAsync(model.Email, model.Password); //var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false); if (user != null) { string userRole = UserManager.GetRoles(user.Id).FirstOrDefault(); Session["userRole"] = userRole; Session["userName"] = model.Email; await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false); return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError("", "Invalid username or password"); return View(model); } } 

Therefore, you can try

 await SignInManager.PasswordSignInAsync 

or

 await SignInManager.SignInAsync 
0
source

All Articles