Home > Mobile >  ArgumentNullException: Value cannot be null. (Parameter 'value')
ArgumentNullException: Value cannot be null. (Parameter 'value')

Time:01-29

I am having trouble with loging in from postman to my API. I get the roles back no problem but when they are used as parameters in the tokenservice they just stop working I get the following error :

enter image description here

The issue might relates the userFromDb, role value or the configuration value, I suggest you could set some break point to check the userFromDb and role value in the Login method and set break point in the TokenService to check whether the token generated success, refer to the following image:

enter image description here

Update: the LoginUser:

public class LoginUser
{
    public string UserName { get; set; }
    public string Password { get; set; }
    public string EmailAddress { get; set; }
}

For the IdentityUser, I'm using the Asp.net core Identity default IdentityUser model. because in your code, the GenerateToken method also use the IdentityUser Model.

I think you it is because I am using my own user instead of IdentityUser

You can check the GenerateToken method and check the userFromDb, might the issue relate it, in the GenerateToken method, you might need to change your code to use your custom user model, instead of the IdentityUser model.

  • Related