// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, LogicticsDbContext dataContext) { // migrate any database changes on startup (includes initial db creation) dataContext.Database.Migrate(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseCookiePolicy(); app.UseSession(); app.Use(async(context, next) => { var JWToken = context.Session.GetString("JWToken"); if (!string.IsNullOrEmpty(JWToken)) { context.Request.Headers.Add("Authorization", "Bearer " + JWToken); } await next(); }); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "MyArea", pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}"); endpoints.MapControllerRoute( name: "default", pattern: "{controller=Auth}/{action=Login}/{id?}"); endpoints.MapRazorPages(); }); }
protected Repo(DbContextOptions <LogicticsDbContext> options) { _db = new LogicticsDbContext(options); }
protected Repo() { _db = new LogicticsDbContext(); }
public HomeController(LogicticsDbContext context) { _context = context; }