public static ConfigureServices ( IMvcBuilder mvcBuilder ) : void | ||
mvcBuilder | IMvcBuilder | |
return | void |
public void ConfigureServices(IServiceCollection services) { ApiConfiguration .ConfigureServices(services) .AddOpenApi() .AddDbContext(configuration); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) => ApiConfiguration.ConfigureServices(services, Environment) .AddCustomServices() .AddOpenApi() .AddCors(options => options.AddPolicy("CorsApi", builder => builder.WithOrigins( "http://localhost:4200", "http://localhost:3000", "http://localhost:8080") .AllowAnyHeader().AllowAnyMethod())) .AddEntityFrameworkCore(Configuration) .AddMediatr() .AddOpenTelemetryTracing(builder => builder .AddAspNetCoreInstrumentation() .AddHttpClientInstrumentation() .AddJaegerExporter() .AddZipkinExporter() ) .AddCustomHealthChecks(Configuration) .AddHashids(setup => { setup.Salt = "your_salt"; setup.MinHashLength = 16; }) .AddSwaggerGen(c => c.OperationFilter <HashIdsOperationFilter>()) .AddResponseCompression() ;
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { ApiConfiguration.ConfigureServices(services) .AddCors() .AddDbContext <ShopContext>(options => { options.UseSqlServer(@"Server=.;Database=Shop;Trusted_Connection=True;"); }); }
// 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 http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { // Register Authentication services.AddAuthentication(options => { options.DefaultScheme = TestServerAuthenticationDefaults.AuthenticationScheme; }) .AddTestServerAuthentication(); ApiConfiguration.ConfigureServices(services); }
public void ConfigureServices(IServiceCollection services) { ApiConfiguration.ConfigureServices(services) .AddDbContext <NotesContext>(options => { options.UseSqlServer(configuration.GetConnectionString(Constants.SqlServer), sqlOptions => { sqlOptions.MigrationsAssembly(typeof(TestStartup).Assembly.FullName); }); }); }
public void ConfigureServices(IServiceCollection services) { ApiConfiguration.ConfigureServices(services) .AddDbContextPool <ApiDbContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("SqlServer"), sqlOptions => { sqlOptions.MigrationsAssembly(typeof(Startup).Assembly.GetName().Name); }); }) .AddControllers(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Register Authentication services.AddAuthentication(options => { options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(options => { options.Authority = "https://localhost:8000"; }); ApiConfiguration.ConfigureServices(services); }
public void ConfigureServices(IServiceCollection services) { ApiConfiguration.ConfigureServices(services); services .AddAuthentication(TestServerDefaults.AuthenticationScheme) .AddTestServer(); services .AddDbContext <ShopContext>(options => { // appsettings.json, Copy to Output Directory: Copy if newer options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")); }); }
public void ConfigureServices(IServiceCollection services) { // Register Authentication services.AddAuthentication(options => { options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(options => { options.Authority = "https://localhost:5001"; }); var mvcBuilder = services.AddControllers(); ApiConfiguration.ConfigureServices(mvcBuilder); }
// 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 http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { // Register Authentication services.AddAuthentication(options => { options.DefaultScheme = TestServerDefaults.AuthenticationScheme; }) .AddTestServer() // We can register as many TestServer authentication options with different scheme names .AddTestServer("bearer", options => { options.NameClaimType = "name"; options.RoleClaimType = "role"; }) .AddTestServer("extra"); ApiConfiguration.ConfigureServices(services); }
// 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 http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { // Register Authentication services.AddAuthentication(options => { options.DefaultScheme = TestServerDefaults.AuthenticationScheme; }) .AddTestServer() // We can register as many TestServer authentication options with different scheme names .AddTestServer("bearer", options => { options.NameClaimType = "name"; options.RoleClaimType = "role"; }) .AddTestServer("extra"); var mvcBuilder = services.AddControllers() .SetCompatibilityVersion(CompatibilityVersion.Version_3_0); ApiConfiguration.ConfigureServices(mvcBuilder); }
public void ConfigureServices(IServiceCollection services) { ApiConfiguration.ConfigureServices(services, Configuration, Environment); services.AddDistributedMemoryCache(); services.AddOpenApi(); var origins = new string[] { "http://localhost:4200", "https://localhost:4200", "http://localhost:3000" }; services.AddCors(options => { options.AddPolicy(AllowedOrigins, builder => { builder.WithOrigins(origins) .AllowAnyHeader() .AllowAnyMethod(); }); }); services.AddEntityFrameworkCore(Configuration) .AddCustomDbContext(Configuration); }
public void ConfigureServices(IServiceCollection services) { ApiConfiguration.ConfigureServices(services, _configuration, _hostEnvironment) .AddDistributedMemoryCache() .RegisterSwaggerExtensions(ApiConstants.ApiTitleV1, ApiConstants.ApiVersionV1) .AddCors(options => options.AddPolicy(AllowedOriginsPolicy, corsbuilder => { var allowedOrigins = _configuration.GetSection <Cors>().AllowedOrigins?.Split(";") ?? throw new ArgumentNullException(AllowedOriginsPolicy); corsbuilder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod() .WithOrigins(allowedOrigins); })) .AddControllers(); if (IsOnlyApi()) { return; } services.AddSpaStaticFiles(configuration => configuration.RootPath = SpaStaticsPath); }
// 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 http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { ApiConfiguration.ConfigureServices(services); }
public void ConfigureServices(IServiceCollection services) { ApiConfiguration.ConfigureServices(services) .AddAuthentication(TestServerAuthenticationDefaults.AuthenticationScheme) .AddTestServerAuthentication(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { ApiConfiguration.ConfigureServices(services) .AddAuthentication() .AddJwtBearer(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { ApiConfiguration.ConfigureServices(services, Environment, Configuration); }
public void ConfigureServices(IServiceCollection services) { ApiConfiguration.ConfigureServices(services, _configuration, _hostingEnvironment) .AddAuthentication(options => options.DefaultScheme = TestServerDefaults.AuthenticationScheme) .AddTestServer(); }