예제 #1
0
        public IActionResult Index()
        {
            if (_environment.IsDebug())
            {
                // only show in development
                return(View());
            }

            _logger.LogInformation("Homepage is disabled in production. Returning 404.");
            return(NotFound());
        }
예제 #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)
        {
            if (env.IsDebug())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

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

            app.UseSwagerConfig();

            ConfigureAdditionalMiddleware(app);

            app.UseAuthentication();

            app.UseAuthorization();

            app.UseMiddleware <ErrorHandlingMiddleware>();


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