Example #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, AppDbContext appDbContext, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment()) // Development
            {
                app.UseDeveloperExceptionPage();
            }
            else // Production
            {
                app.UseExceptionHandler("/Error");
            }


            app.UseCors(builder =>
                        builder
                        .AllowAnyOrigin()
                        .AllowAnyHeader()
                        .AllowAnyMethod());

            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            app.UseStaticFiles();

            DataSeedingIntilization.Seed(appDbContext, serviceProvider);


            if (this.Configuration.GetValue <bool>("EnableSwagger"))
            {
                app.UseSwagger();

                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint(
                        "../swagger/v1/swagger.json",
                        $"Insurance Claims v1 ({this.WebHostEnvironment.EnvironmentName})");

                    c.OAuthClientId("test");
                    c.OAuthAppName("Insurance Claims ApiGateway");
                });
            }
        }
Example #2
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider, UserDbContext userDbContext, TaskDbContext taskDbContext)
        {
            app.UseRequestLocalization();
            var requestOpt = new RequestLocalizationOptions();

            requestOpt.SupportedCultures = new List <CultureInfo> {
                new CultureInfo("en-US")
            };
            requestOpt.SupportedUICultures = new List <CultureInfo> {
                new CultureInfo("en-US")
            };
            requestOpt.RequestCultureProviders.Clear();
            requestOpt.RequestCultureProviders.Add(new SingleCultureProvider());
            app.UseRequestLocalization(requestOpt);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }


            app.UseHttpsRedirection();

            app.UseCors(option =>
            {
                option.WithOrigins("http://localhost:4200").AllowAnyMethod().AllowAnyHeader();
            });

            app.UseRouting();

            app.UseAuthorization();

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseAuthentication();

            DataSeedingIntilization.Seed(userDbContext, serviceProvider);
            TaskDataSeedingIntilization.Seed(taskDbContext);

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Example #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, AppDbContext appDbContext, IServiceProvider serviceProvider)
        {
            if (env.IsEnvironment("Local"))
            {
                app.UseCors(builder =>
                            builder
                            .AllowAnyOrigin()
                            .AllowAnyHeader()
                            .AllowAnyMethod());

                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");

                app.UseSpa(spa =>
                {
                    // To learn more about options for serving an Angular SPA from ASP.NET Core,
                    // see https://go.microsoft.com/fwlink/?linkid=864501

                    spa.Options.SourcePath = "ClientApp";

                    if (env.IsDevelopment())
                    {
                        spa.UseAngularCliServer(npmScript: "start");
                        //spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");
                    }
                });

                app.UseSpaStaticFiles();
            }

            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            app.UseStaticFiles();

            DataSeedingIntilization.Seed(appDbContext, serviceProvider);


            if (this.Configuration.GetValue <bool>("EnableSwagger"))
            {
                app.UseSwagger();

                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint(
                        "../swagger/v1/swagger.json",
                        $"Costing Management v1 ({this.WebHostEnvironment.EnvironmentName})");

                    c.OAuthClientId("test");
                    c.OAuthAppName("Costing Management ApiGateway");
                });
            }
        }