Код: Выделить всё
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(s =>
{
NavigationManager uriHelper = s.GetRequiredService();
return new HttpClient
{
BaseAddress = new Uri(uriHelper.BaseUri)
};
});
}
services.AddRazorPages();
services.AddServerSideBlazor();
services.AddTransient(s =>
{
NavigationManager uriHelper = s.GetRequiredService();
Uri currentUrl= uriHelper.ToAbsoluteUri(uriHelper.BaseUri);
return new LiteDbContext(new LiteDatabase(this.GetUserDatabasePath(currentUrl)));
}
);
//services.AddTransient();
services.AddIdentity(options =>
{
options.Password.RequireDigit = false;
options.Password.RequireUppercase = false;
options.Password.RequireLowercase = false;
options.Password.RequireNonAlphanumeric = false;
options.Password.RequiredLength = 6;
})
.AddUserStore()
.AddRoleStore()
.AddDefaultTokenProviders();
InvalidOperationException: «RemoteNavigationManager» не был инициализирован.
< img alt="введите описание изображения здесь" src="https://i.sstatic.net/6PPoZ.png" />
Насколько я понял, NavigationManager не инициализируется когда Identity инициализируется. Есть ли способ получить текущий URL-адрес без NavigationManager?
Подробнее здесь: https://stackoverflow.com/questions/623 ... reservices
Мобильная версия