title: IdentityServer4 can't add asp net core identity with custom user store
body: <p>I'm trying to use my custom IUserStore implementation with IdentityServer4 + Asp Net Core Identity, the steps that I followed are creating new 'IdentityServer with Asp Net Core Identity' aka is4aspid template after removing EntityFramework assets then my configure services look like</p>
  <pre><code>    public void ConfigureServices(IServiceCollection services)
      {
          services.AddControllersWithViews();
  
          services.AddScoped&lt;IIdentityUserRepository&lt;ApplicationUser&gt;, IdentityUserRepository&gt;(); //&lt;-- Repository that I used on CustomUserStore
  
          services.AddDefaultIdentity&lt;ApplicationUser&gt;()
              .AddUserStore&lt;CustomUserStore&lt;ApplicationUser&gt;&gt;() //&lt;-- Add
              .AddDefaultTokenProviders();
  
          var builder = services.AddIdentityServer(options =&gt;
              {
                  options.Events.RaiseErrorEvents = true;
                  options.Events.RaiseInformationEvents = true;
                  options.Events.RaiseFailureEvents = true;
                  options.Events.RaiseSuccessEvents = true;
  
                  // see https://identityserver4.readthedocs.io/en/latest/topics/resources.html
                  options.EmitStaticAudienceClaim = true;
              })
              .AddInMemoryIdentityResources(Config.IdentityResources)
              .AddInMemoryApiScopes(Config.ApiScopes)
              .AddInMemoryClients(Config.Clients)
              .AddAspNetIdentity&lt;ApplicationUser&gt;();
      }
  </code></pre>
  <p>And the custom user store looks like</p>
  <pre><code>public class CustomUserStore&lt;TUser&gt; :
      IUserStore&lt;TUser&gt;,
      IUserLoginStore&lt;TUser&gt;,
      IUserRoleStore&lt;TUser&gt;,
      IUserClaimStore&lt;TUser&gt;,
      IUserPasswordStore&lt;TUser&gt;,
      IUserSecurityStampStore&lt;TUser&gt;,
      IUserEmailStore&lt;TUser&gt;,
      IUserLockoutStore&lt;TUser&gt;,
      IUserPhoneNumberStore&lt;TUser&gt;
      where TUser : ApplicationUser
  {
      private readonly IIdentityUserRepository&lt;TUser&gt; _userRepository;
  
      public CustomUserStore(IIdentityUserRepository&lt;TUser&gt; userRepository)
      {
          _userRepository = userRepository;
      } //rest of the code hidden sake of brevity
  </code></pre>
  <p>Custom user store works well with default Asp Net Core identity template but in is4aspid template when I try to get rid of Entity Framework and put my custom store implementation, Login page returns 404 message when I try to access protected resource but aside from that, home page works properly, there is no error message or log aside message below</p>
  <pre><code>[13:03:04 Information] Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler
  AuthenticationScheme: Identity.Application was challenged.
  </code></pre>
  <p>Also while these things happening there is no call to the Controllers or the CustomUserStore</p>
  <p>Documentations that I used</p>
  <p><a href="https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity-custom-storage-providers?view=aspnetcore-5.0" rel="nofollow noreferrer">Custom storage providers for ASP.NET Core Identity</a></p>
  <p><a href="http://docs.identityserver.io/en/latest/quickstarts/6_aspnet_identity.html" rel="nofollow noreferrer">IdentityServer4 Using ASP.NET Core Identity</a></p>
  <p>Edit: ApplicationUser class is custom implementation as well without any inheritors unlike default <code>ApplicationUser : IdentityUser</code> comes with template itself</p>