UserManager value is null for first time to the function FindByNameAsync() RRS feed

  • Question

  • var userManager = context.OwinContext.GetUserManager<ApplicationUserManager>();
    var user = await userManager.FindByNameAsync(context.UserName);

    I have got the value in context.UserName and the same username is existed in DB. But FindByNameAsync() function returning null sometimes for the first call.

    if I call same function again it is giving output as expected. when I call it as in the below code.

    if(user == null) {

    var user = await userManager.FindByNameAsync(context.UserName);


    Please help me.

    Many thanks in advance for the help.

    Note : it is not happening every time but happening quite often.

    • Moved by CoolDadTx Friday, August 9, 2019 1:49 PM ASP.NET related
    Friday, August 9, 2019 7:54 AM

All replies

  • Please post questions related to ASP.NET in the ASP.NET forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Friday, August 9, 2019 1:49 PM