I work on .net core 7 blazor web app . i face issue when working on identity user register .

when debug on function userManager.FindByNameAsync it hang and stuck

so I try to add watch to function userManager.FindByNameAsync to check reason

I get message function evaluation require all thread to run when make add

so How to solve this issue please And are that will make hang on run time application run on IIS .

my code generate error

public async Task<ResponseModel> Submit(UserDto request)
                string roleName = request.UserRole == 1 ? "Normal" : "Admin";
                request.EmailAddress = "xyza3211116@gmail.com";
                var Identityuser = await userManager.FindByNameAsync(request.UserName);
                var newUserIdentity = new ApplicationUser()
                    FullName = request.UserName,
                    Email = request.EmailAddress,
                    UserName = request.UserName
                var newUserResponse = await userManager.CreateAsync(newUserIdentity, "Cxx90111@7777?");

when debug it hangs on two variables Identityuser and newUserResponse

and give me function evaluation require all thread to run When make add watch to these two function userManager.CreateAsync and userManager.FindByNameAsync

so How to ignore this message and resume debugging AND see my result without hang

from debug

newUserResponse

variable

Id = 1127, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"

I using user manager for microsoft
 private readonly UserManager<IdentityUser> userManager;
        private readonly RoleManager<IdentityRole> roleManager;
        private readonly SignInManager<ApplicationUser> _signInManager;
name space used
using Microsoft.AspNetCore.Identity;
											

Can you proved basic information? Is this Blazor WASM or Server. Is the code you shared running in a Web API Application? Did you use a template to create this solution and if so what template? Can you provide the program.cs configuration for Identity?

Keep in mind, Blazor WASM runs in the browser. The Identity API must run on a server.

thank you for support

this is solved

var Identityuser = userManager.FindByNameAsync(request.UserName).Result; --solved

but still can't add role

userManager.AddToRoleAsync(newUserIdentity, roleName).Result; --still yet not solving

issue on bold line on function submit

it give me same issue function evaluation require all thread to run

full code details

public class ResponseModel
    public object result { get; set; }
    public string message { get; set; }
    public Status status { get; set; }
    public void Success(object data)
        result = data;
        message = "success";
        status = Status.success;
    public void Success()
        result = null;
        message = "success";
        status = Status.success;
    public void Failed(string errorMsg)
        result = null;
        message = errorMsg;
        status = Status.InternalServerError;
    public void PartiallySucceed(string errorMsg)
        result = null;
        message = "partially Succeed : " + errorMsg;
        status = Status.success;
public enum Status
    success = 200,
    SuccessButDataNoFound = 404,
    InternalServerError = 500,
    Unauthorized = 401,
    BadRequest = 404
    public async Task<ResponseModel> Submit(UserDto request)
            string roleName = request.UserRole == 1 ? "Normal" : "Admin";
            request.EmailAddress = "Mchelaziz.ga.ba@gmail.com";
            var Identityuser =   userManager.FindByNameAsync(request.UserName).Result;
            var newUserIdentity = new IdentityUser()
                UserName = request.UserName
            var newUserResponse =  userManager.CreateAsync(newUserIdentity, "Cxyz90191@1234?").Result;
            //if (newUserResponse.Succeeded)
                **var a=    userManager.AddToRoleAsync(newUserIdentity, roleName).Result;//issue here** 
            if (Identityuser == null)
                //First Check If User Exist
                var UserExsit = _UsersRepository.GetList(x => x.UserName == request.UserName).FirstOrDefault();
                if (UserExsit == null)
                    //check the User is on Active Directory
                    string adPath = "LDAP://DC=XXX,DC=XX";
                    var adAuth = new LdapAuthentication(adPath).userexists(request.UserName, "xx");
                    if (adAuth)
                        var newUser = new Users();
                        newUser.UserName = request.UserName;
                        newUser.IsActive = true;
                        newUser.UserRoll = request.UserRole;
                        newUser.UserType = request.UserType;
                        newUser.CreatedBy = 1;
                        newUser.CreatedDate = DateTime.Now;
                        var result = _UsersRepository.Insert(newUser);
                        if (result.ID != 0)
                            IdentityRole role_ = new IdentityRole(roleName);
                            var exists = await roleManager.RoleExistsAsync(roleName);
                            if (!exists)
                                var results = await roleManager.CreateAsync(role_);
                                if (results.Succeeded)
                                    var user_ = await userManager.CreateAsync(new IdentityUser { UserName = result.UserName, NormalizedUserName = result.UserName });
                                    var user = await userManager.FindByNameAsync(request.UserName);
                                    await userManager.AddToRoleAsync(user, roleName);
                                var user_ = await userManager.CreateAsync(new IdentityUser { UserName = result.UserName, NormalizedUserName = result.UserName });
                                var user = await userManager.FindByNameAsync(request.UserName);
                                await userManager.AddToRoleAsync(user, roleName);
                            _response.Success(newUser);
                            _response.Failed("Sorry, Failed to Registeration User");
                        _response.Failed("Sorry, The User Not Exist in Active Directory");
                    _response.Failed("Sorry, The User Is Already Exist");
                _response.Failed("Sorry, The User Is Already Exist");
											

Using .Result is a really bad idea because it wastes system resources.

Did you check the value of Identityuser? Is it null?

AddToRoleAsync returns IdentityResult. Did you check the results?

Also, you did not answer a single question I originally asked. Is this Blazor WASM or Server? Is the code you've shown running in Web API?