Hello, I am trying to implement cognito user pool into my login, register and logout and I have tried this code for Signup
- protected void Button1_Click(object sender, EventArgs e)
- {
- AddCognitoUser();
- }
- static async Task AddCognitoUser()
- {
- string username = "Name";
- string password = "Password";
- string phonenumber = "+678172932";
- string email = "[email protected]";
- AmazonCognitoIdentityProviderClient provider =
- new AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials());
- SignUpRequest signUpRequest = new SignUpRequest();
- signUpRequest.ClientId = "clientid";
- signUpRequest.Username = username;
- signUpRequest.Password = password;
-
- AttributeType attributeType = new AttributeType();
- attributeType.Name = "phone_number";
- attributeType.Value = phonenumber;
- signUpRequest.UserAttributes.Add(attributeType);
-
- AttributeType attributeType1 = new AttributeType();
- attributeType1.Name = "email";
- attributeType1.Value = email;
- signUpRequest.UserAttributes.Add(attributeType1);
-
- try
- {
- SignUpResponse result = await provider.SignUpAsync(signUpRequest);
- }
- catch (Exception e)
- {
- System.Diagnostics.Debug.WriteLine(e);
- }
- }
When i run these codes, there is an error saying "An unhandled exception of type 'System.NullReferenceException' occurred in mscorlib.dll" and i tried to find but there is nothing null in the codes. Is there anything that i do wrong?
Or is there any other better tutorial that help to integrate cognito with asp.net c#?
Any help will be really helpful.
Thank You.