© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•17mo ago•
10 replies
clownshark5503

[solved]Stuck on a The input is not a valid Base-64 string error

Here is the full error message: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

The error shows up when I use my login endpoint when _signInManager.CheckPasswordSignInAsync manager is called.

 [HttpPost("login")]
 public async Task<IActionResult> Login(LoginDto loginDto)
 {
     if (!ModelState.IsValid)
         return BadRequest(ModelState);
     
     var user = await _userManager.Users.FirstOrDefaultAsync(x => x.Email == loginDto.Email);

     if (user == null)
         return Unauthorized("Invalid Email");

   
var result = await _signInManager.CheckPasswordSignInAsync(user, loginDto.Password,false);
    
 
     if (!result.Succeeded)
         return Unauthorized("Email or Password not found/incorrect");

     return Ok(
         new NewUserDto
         {
         
             Email = user.Email,
             Token = _tokenService.CreateToken(user)
         });
 }
 [HttpPost("login")]
 public async Task<IActionResult> Login(LoginDto loginDto)
 {
     if (!ModelState.IsValid)
         return BadRequest(ModelState);
     
     var user = await _userManager.Users.FirstOrDefaultAsync(x => x.Email == loginDto.Email);

     if (user == null)
         return Unauthorized("Invalid Email");

   
var result = await _signInManager.CheckPasswordSignInAsync(user, loginDto.Password,false);
    
 
     if (!result.Succeeded)
         return Unauthorized("Email or Password not found/incorrect");

     return Ok(
         new NewUserDto
         {
         
             Email = user.Email,
             Token = _tokenService.CreateToken(user)
         });
 }


Here are things I've tried:
1. Encoding loginDto.Password into a base64 string
2. Modifying thesigningkey, making it longer and shorter. Making sure it takes up 64 bytes.

The stack trace is too big for discord so it'll be in a comment

SOLUTION: The problem was that the password in the database wasn't encoded in base64
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Base64 invalid string error while the input is valid
C#CC# / help
3y ago
✅ input string is not correct format
C#CC# / help
4y ago
❔ "string was not recognised as valid DateTime"
C#CC# / help
3y ago
It's working fine but the error is 'Input string was not in a correct format.'
C#CC# / help
3y ago