title: Blazor. How can I get current url in the Startup class (method ConfigureServices)?
body: <p>I am using AspNetCore.Identity.LiteDB. The database name depends on hostname. I am trying to get hostname using NavigationManager but it seems in the Startup.ConfigureServices it is not initialized.</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
      {
         // Server Side Blazor doesn't register HttpClient by default
          if (!services.Any(x =&gt; x.ServiceType == typeof(HttpClient)))
          {
              // Setup HttpClient for server side in a client side compatible fashion
              services.AddScoped&lt;HttpClient&gt;(s =&gt;
              {
                  NavigationManager uriHelper = s.GetRequiredService&lt;NavigationManager&gt;();
                  return new HttpClient
                  {
                      BaseAddress = new Uri(uriHelper.BaseUri)
                  };
              });
          }
  
          services.AddRazorPages();
          services.AddServerSideBlazor();
          services.AddTransient&lt;ILiteDbContext&gt;(s =&gt;
                  {
                      NavigationManager uriHelper = s.GetRequiredService&lt;NavigationManager&gt;();
                      Uri currentUrl= uriHelper.ToAbsoluteUri(uriHelper.BaseUri);
                      return new LiteDbContext(new LiteDatabase(this.GetUserDatabasePath(currentUrl)));
                  }
              );
  
          //services.AddTransient&lt;ILiteDbContext, LiteDbContext&gt;();
          services.AddIdentity&lt;ApplicationUser, AspNetCore.Identity.LiteDB.IdentityRole&gt;(options =&gt;
          {
              options.Password.RequireDigit = false;
              options.Password.RequireUppercase = false;
              options.Password.RequireLowercase = false;
              options.Password.RequireNonAlphanumeric = false;
              options.Password.RequiredLength = 6;
          })
          .AddUserStore&lt;LiteDbUserStore&lt;ApplicationUser&gt;&gt;()
          .AddRoleStore&lt;LiteDbRoleStore&lt;AspNetCore.Identity.LiteDB.IdentityRole&gt;&gt;()
          .AddDefaultTokenProviders();
  </code></pre>
  
  <p>I have the exception: 
  InvalidOperationException: 'RemoteNavigationManager' has not been initialized.</p>
  
  <p><a href="https://i.stack.imgur.com/6PPoZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6PPoZ.png" alt="enter image description here"></a></p>
  
  <p>As I understood NavigationManager is not initialized when Identity is being initialized. Is there a way to get the current URL without NavigationManager? </p>