title: how to use usermanager on a blazor page?
body: <p>hello community I have a question how can I use <code>usermanager</code> in a <code>blazor</code> page webassembly ? by injecting this:</p>
  <pre><code>@inject UserManager&lt;ApplicationUser&gt; UserManager;
  </code></pre>
  <p>I get the indication that a usage directive is missing as the class the ApplicationUser class is on the server and the client does not have access to the server.</p>
  <p>this is my code in blazor page:</p>
  <pre><code>@page &quot;/index&quot;
  @inject AuthenticationStateProvider AuthenticationStateProvider
  @using Microsoft.AspNetCore.Identity;
  @inject UserManager&lt;ApplicationUser&gt; UserManager;
  
  &lt;button @onclick=&quot;@LogUsername&quot;&gt;Write user info to console&lt;/button&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  @Message
  
  @code {
      string Message = &quot;&quot;;
  
      private async Task LogUsername()
      {
          var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
          var user = authState.User;
  
          if (user.Identity.IsAuthenticated)
          {
              var currentUser = await UserManager.GetUserAsync(user);
              Message = ($&quot;{user.Identity.Name} is authenticated.{ currentUser.Nombre }&quot;);
          }
          else
          {
              Message = (&quot;The user is NOT authenticated.&quot;);
          }
      }
  }
  </code></pre>
  <p>This is my class ApplicationUser:</p>
  <pre class="lang-cs prettyprint-override"><code>    public class ApplicationUser: IdentityUser
          {
              public string Nombre { get; set; }
              public string ApellidoPaterno { get; set; }
              public string ApellidoMaterno { get; set; }
              public virtual Cliente InquilinoActual { get; set; }
          }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/rsuuE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rsuuE.png" alt="Image of an SQL Query" /></a></p>