Exemple #1
0
        public void Configure(IApplicationBuilder app)
        {
            app.UseHttpsRedirection();

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

            if (Environment.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();

                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity MS"));
            }
            else
            {
                app.UseExceptionHandler(a => a.Run(async context =>
                {
                    var result = JsonConvert.SerializeObject(ErrorDto.FromRequestId(context.TraceIdentifier));
                    context.Response.ContentType = MediaTypeNames.Application.Json;
                    await context.Response.WriteAsync(result);
                }));
            }

            app.UseRouting();

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

            app.RunMigrations <IdentityDbContext>(true, Configuration.GetConnectionString("Default"));
        }