// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { var connectionString = Configuration["connectionStrings:dbconn"]; services.AddDbContext <AppDBContext>(options => options.UseSqlServer( connectionString)); services.AddIdentity <AppUser, AppRole>(options => { options.SignIn.RequireConfirmedEmail = false; options.User.AllowedUserNameCharacters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+\"; }) .AddEntityFrameworkStores <AppDBContext>(); services.AddRazorPages(); services.AddServerSideBlazor(); //SQL database Connnection(name defined in appsettings.json) var SQLConnectionConfiguration = new SQLConnectionConfiguration(Configuration.GetConnectionString("dbconn")); services.AddSingleton(SQLConnectionConfiguration); // services.AddServerSideBlazor(o => o.DetailedErrors = true); //services.AddScoped<AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider<AppUser>>() services.AddBlazoredSessionStorage(); services.AddScoped <AuthenticationStateProvider, CustomAuthenticationStateProvider>(); services.AddScoped <DapperManager, DapperManager>(); services.AddTransient <IdentitySeeder>(); services.AddTransient <EmailService>(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var connectionString = Configuration["connectionStrings:dbconn"]; services.AddDbContext <AppDBContext>(options => options.UseSqlServer( connectionString)); services.AddIdentity <AppUser, AppRole>(options => { options.SignIn.RequireConfirmedEmail = false; options.User.AllowedUserNameCharacters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+\"; }) .AddEntityFrameworkStores <AppDBContext>(); services.AddRazorPages(); services.AddServerSideBlazor(); //SQL database Connnection(name defined in appsettings.json) var SQLConnectionConfiguration = new SQLConnectionConfiguration(connectionString); services.AddSingleton(SQLConnectionConfiguration); services.AddScoped <DapperManager, DapperManager>(); services.AddTransient <IdentitySeeder>(); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = Configuration["Jwt:issuer"], ValidAudience = Configuration["Jwt:issuedTo"], IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:Key"])) }; }); ConfigureSwagger(services); services.AddControllers(); }