Ejemplo n.º 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, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();
            ApplicationLogging.ConfigureNlogLogger(loggerFactory);
            app.UseRouting();

            // global cors policy
            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader());

            app.UseAuthentication();
            app.UseAuthorization();

            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "API V1.0");
            });

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseMiddleware <StackifyMiddleware.RequestTracerMiddleware>();
            }
            else
            {
                app.ConfigureCustomExceptionMiddleware();
                app.UseStatusCodePagesWithReExecute("/Error/{0}");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }


            ApplicationLogging.ConfigureNlogLogger(loggerFactory);
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();
            app.UseBigBizInsuranceTenant();
            #region localization
            app.UseGlobalization();
            app.UseRouter(EmbeddedResourcesConfigRouter.RegisterGlobalizationRoutes(app));

            IList <CultureInfo> supportedCultures = new List <CultureInfo>
            {
                new CultureInfo("en-US"), //English US
                new CultureInfo("ar-SA"), //Arabic SA
            };
            var localizationOptions = new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture("en-US"), //English US will be the default culture (for new visitors)
                SupportedCultures     = supportedCultures,
                SupportedUICultures   = supportedCultures
            };

            app.UseRequestLocalization(localizationOptions);

            // var locOptions = app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>();
            // app.UseRequestLocalization(locOptions.Value);
            #endregion


            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
                endpoints.MapControllers();
            });
        }