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.
public void ConfigureServices(IServiceCollection services) { // Server Side Blazor doesn't register HttpClient by default if (!services.Any(x => x.ServiceType == typeof(HttpClient))) { // Setup HttpClient for server side in a client side compatible fashion services.AddScoped<HttpClient>(s => { NavigationManager uriHelper = s.GetRequiredService<NavigationManager>(); return new HttpClient { BaseAddress = new Uri(uriHelper.BaseUri) }; }); } services.AddRazorPages(); services.AddServerSideBlazor(); services.AddTransient<ILiteDbContext>(s => { NavigationManager uriHelper = s.GetRequiredService<NavigationManager>(); Uri currentUrl= uriHelper.ToAbsoluteUri(uriHelper.BaseUri); return new LiteDbContext(new LiteDatabase(this.GetUserDatabasePath(currentUrl))); } ); //services.AddTransient<ILiteDbContext, LiteDbContext>(); services.AddIdentity<ApplicationUser, AspNetCore.Identity.LiteDB.IdentityRole>(options => { options.Password.RequireDigit = false; options.Password.RequireUppercase = false; options.Password.RequireLowercase = false; options.Password.RequireNonAlphanumeric = false; options.Password.RequiredLength = 6; }) .AddUserStore<LiteDbUserStore<ApplicationUser>>() .AddRoleStore<LiteDbRoleStore<AspNetCore.Identity.LiteDB.IdentityRole>>() .AddDefaultTokenProviders();I have the exception: InvalidOperationException: 'RemoteNavigationManager' has not been initialized.
As I understood NavigationManager is not initialized when Identity is being initialized. Is there a way to get the current URL without NavigationManager?
