using Microsoft.Extensions.WebEncoders; using SwaggerFilter.Filters; using System.Reflection; using System.Text.Encodings.Web; using System.Text.Unicode; var log4netRepository = log4net.LogManager.GetRepository(Assembly.GetEntryAssembly()); log4net.Config.XmlConfigurator.Configure(log4netRepository, new FileInfo("log4net.config")); var builder = WebApplication.CreateBuilder(args); var services = builder.Services; // Add services to the container. builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); //HttpContext 사용 services.AddSingleton(); //Session 사용 /* services.AddDistributedMemoryCache(); services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(120); options.Cookie.HttpOnly = true; options.Cookie.IsEssential = true; }); */ services.AddSwaggerGen(gen => { gen.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Version = "v1", Title = "Report API NET 6.0", Description = "KRI Report API NET 6.0" }); gen.DocumentFilter(); gen.ResolveConflictingActions(apiDescriptions => apiDescriptions.First()); }); services.Configure(options => { options.TextEncoderSettings = new TextEncoderSettings(UnicodeRanges.All); // 한글이 인코딩되는 문제 해결 }); services.AddCors(options => { options.AddDefaultPolicy( policy => { policy.AllowAnyHeader() .AllowAnyMethod() .AllowAnyOrigin() .WithExposedHeaders(new string[] { "Content-Disposition"}); }); }); //Server Path사용 AppDomain.CurrentDomain.SetData("ContentRootPath", Environment.CurrentDirectory); var app = builder.Build(); app.UseCors(); //Session 사용 //app.UseSession(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment() || app.Environment.IsProduction()) { app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Showing API V1"); }); } app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run();