You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I tried to re-create this to dotnet core 6 for my project, I believe nothing wrong with my code becuase I tried to copy and paste and modify one by one. but when I try for register, _userManager is null
Expected behavior _userManager in AccountService is populated or not null
Screenshots
Desktop (please complete the following information):
OS: Mac
Browser Chrome
Additional context
this is my program.cs in web api
using Application;using Application.Interfaces;using Infrastructure.Identity;using Infrastructure.Persistence;using Infrastructure.Identity.Models;using Microsoft.AspNetCore.Identity;using Microsoft.AspNetCore.Mvc;using Readbuk.Api.Services;varbuilder= WebApplication.CreateBuilder(args);
builder.Services.AddApplication();
builder.Services.AddIdentityInfrastructure(builder.Configuration);
builder.Services.AddPersistenceInfrastructure(builder.Configuration);// Add services to the container.
builder.Services.AddControllers();// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddScoped<IAuthenticatedUserService,AuthenticatedUserService>();
#region API Versioning
// Add API Versioning to the Project
builder.Services.AddApiVersioning(config =>{// Specify the default API Version as 1.0 config.DefaultApiVersion =new ApiVersion(1,0);// If the client hasn't specified the API version in the request, use the default API version number config.AssumeDefaultVersionWhenUnspecified =true;// Advertise the API versions supported for the particular endpoint config.ReportApiVersions =true;});
#endregion
varapp= builder.Build();// Configure the HTTP request pipeline.if(app.Environment.IsDevelopment()){
app.UseSwagger();
app.UseSwaggerUI();varscopeFactory= app.Services.GetRequiredService<IServiceScopeFactory>();using(varscope= scopeFactory.CreateScope()){varroleManager= scope.ServiceProvider.GetRequiredService<RoleManager<IdentityRole>>();varuserManager= scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();//await DefaultRoles.SeedAsync(userManager, roleManager);//await DefaultBasicUser.SeedAsync(userManager, roleManager);//await DefaultSuperAdmin.SeedAsync(userManager, roleManager);}}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
The text was updated successfully, but these errors were encountered:
Describe the bug
I tried to re-create this to dotnet core 6 for my project, I believe nothing wrong with my code becuase I tried to copy and paste and modify one by one. but when I try for register,
_userManager
is nullExpected behavior
_userManager
inAccountService
is populated or not nullScreenshots
Desktop (please complete the following information):
Additional context
this is my program.cs in web api
The text was updated successfully, but these errors were encountered: