// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDistributedMemoryCache(); services.AddSession(options => { options.IdleTimeout = TimeSpan.FromSeconds(10); options.Cookie.HttpOnly = true; options.Cookie.IsEssential = true; }); // CONFIGURAÇÃO DA CONEXÃO COM O DB E O CONTEXT var connection = Configuration["ConexaoSqlite:SqliteConnectionString"]; ConfigureContext <MyContext> .Configure(services, connection); // CONFIGURAÇÃO DA INJEÇÃO DE DEPENDÊNCIA ConfigureDependencyInjection.Configuration(services); services.AddControllers().AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore ); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddControllersWithViews(); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); ConfigureContext.Configure(); }