title: ArgumentNullException: String reference not set to an instance of a String. Parameter name: s System.Text.Encoding.GetBytes(string s)
body: <p>I have this method to generate token:</p>
  
  <pre><code>[HttpPost("login")]
          public async Task&lt;IActionResult&gt; login(UserForLoginDto userForLoginDto)
          {
              var userFromRepo = await _repo.Login(userForLoginDto.Username.ToLower(), userForLoginDto.Password);
  
              if(userFromRepo == null)
                 return Unauthorized();
  
              var claims = new[]
              {
                  new Claim(ClaimTypes.NameIdentifier, userFromRepo.Id.ToString()),
                  new Claim(ClaimTypes.Name, userFromRepo.Username)
              };   
  
              var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config.GetSection("AppSettings:Token").Value));
  
              var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha512Signature);
  
              var tokenDescriptor = new SecurityTokenDescriptor
              {
                  Subject = new ClaimsIdentity(claims),
                  Expires = DateTime.Now.AddDays(1),
                  SigningCredentials = creds
              };
  
              var tokenHandler = new JwtSecurityTokenHandler();
  
              var token = tokenHandler.CreateToken(tokenDescriptor);
  
              return Ok(new{
                  token = tokenHandler.WriteToken(token)
              });
  
          }
  </code></pre>
  
  <p>When I call this API via postman :</p>
  
  <blockquote>
    <p>localhost:5000/api/auth/login</p>
    
    <p>In body username: "john", password: "password" </p>
  </blockquote>
  
  <p>I got this error:</p>
  
  <blockquote>
    <p>An unhandled exception occurred while processing the request.
    ArgumentNullException: String reference not set to an instance of a
    String. Parameter name: s System.Text.Encoding.GetBytes(string s)</p>
  </blockquote>
  
  <p>because of this line :</p>
  
  <pre><code>var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config.GetSection("AppSettings:Token").Value));
  </code></pre>
  
  <p>Kindly help to fix this error.</p>