title: Using asp.net roles in a blazor page
body: <p>I want to use asp.net Usermanager in a blazor server-side page in order to get the Roles of a user</p>
  <p>to achieve that, I have to use the UserManager but if I try with [Inject] I get an error when I do services.Addxx&lt;&gt; in startup.cs</p>
  <blockquote>
  <p>Unable to resolve service for type 'Microsoft.AspNetCore.Identity.IUserStore'1[Data.ApplicationDbContext]' while attempting to activate 'Microsoft.AspNetCore.Identity.UserManager'1[Data.ApplicationDbContext]'.</p>
  </blockquote>
  <p>Else if I try to use in the constructor I get this error:</p>
  <blockquote>
  <p>Error  CS7036  There is no argument given that corresponds to the required formal parameter 'userManager' of 'InvoiceListBase.InvoiceListBase(UserManager)'</p>
  </blockquote>
  <pre><code>[CascadingParameter] Task&lt;AuthenticationState&gt; AuthenticationStateTask { get; set; } 
  private readonly UserManager&lt;ApplicationDbContext&gt; _userManager;
  public IList&lt;String&gt; Roles { get; set; }
  
  public InvoiceListBase(UserManager&lt;ApplicationDbContext&gt; userManager)
  {
      _userManager = userManager;
  }
  
  protected override async Task OnInitializedAsync()
  {
      var authstate = await AuthenticationStateTask;
      var user = await _userManager.GetUserAsync(authstate.User);
      Roles = await _userManager.GetRolesAsync(user);
  }
  </code></pre>
  <p>Thanks</p>