// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { ConfigureCookieSettings.Configure(services); services.AddIdentity <ApplicationUser, IdentityRole>() .AddDefaultUI() .AddEntityFrameworkStores <AppIdentityDbContext>() .AddDefaultTokenProviders(); services.AddScoped <ITokenClaimsService, IdentityTokenClaimService>(); ConfigureCoreServices.Configure(services, Configuration); ConfigureWebServices.Configure(services, Configuration); // Add memory cache services services.AddMemoryCache(); services.AddRouting(options => { // Replace the type and the name used to refer to it with your own // IOutboundParameterTransformer implementation options.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer); }); services.AddMvc(options => { options.Conventions.Add(new RouteTokenTransformerConvention( new SlugifyParameterTransformer())); }); services.AddControllersWithViews(); services.AddRazorPages(options => { options.Conventions.AuthorizePage("/Basket/Checkout"); }); services.AddHttpContextAccessor(); services.AddHealthChecks(); services.Configure <ServiceConfig>(config => { config.Services = new List <ServiceDescriptor>(services); config.Path = "/allservices"; }); // Blazor Admin Required Services for Prerendering services.AddScoped <HttpClient>(s => { var navigationManager = s.GetRequiredService <NavigationManager>(); return(new HttpClient { //TODO need to do it well BaseAddress = new Uri("https://localhost:44315/") //BaseAddress = new Uri(navigationManager.BaseUri) }); }); services.AddBlazoredLocalStorage(); services.AddServerSideBlazor(); services.AddScoped <AuthService>(); _services = services; // used to debug registered services }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { ConfigureCookieSettings.Configure(services); services.AddIdentity <ApplicationUser, IdentityRole>() .AddDefaultUI() .AddEntityFrameworkStores <AppIdentityDbContext>() .AddDefaultTokenProviders(); ConfigureCoreServices.Configure(services, Configuration); ConfigureWebServices.Configure(services, Configuration); // Add memory cache services services.AddMemoryCache(); services.AddRouting(options => { // Replace the type and the name used to refer to it with your own // IOutboundParameterTransformer implementation options.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer); }); services.AddMvc(options => { options.Conventions.Add(new RouteTokenTransformerConvention( new SlugifyParameterTransformer())); }); services.AddRazorPages(options => { options.Conventions.AuthorizePage("/Basket/Checkout"); }); services.AddControllersWithViews(); services.AddHttpContextAccessor(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApi.Models.OpenApiInfo { Title = "My API", Version = "v1" }); c.EnableAnnotations(); c.SchemaFilter <CustomSchemaFilters>(); }); services.AddHealthChecks(); services.Configure <ServiceConfig>(config => { config.Services = new List <ServiceDescriptor>(services); config.Path = "/allservices"; }); _services = services; // used to debug registered services }