public Startup(IConfiguration configuration) { PasteDatabase.Init(); AssemblyLoadContext.Default.Unloading += (context) => { PasteDatabase.Shutdown(); }; AppDomain.CurrentDomain.ProcessExit += (obj, e) => { PasteDatabase.Shutdown(); }; Configuration = configuration; }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime lifetime) { lifetime.ApplicationStopping.Register(() => { PasteDatabase.Shutdown(); }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error/Any"); } PasteServer.LoadConfig(); app.Use(async(context, next) => { string path = context.Request.Path.Value.ToLowerFast(); if (path.StartsWith("/view/") && !path.StartsWith("/view/index")) { context.Items["viewable"] = path[("/view/".Length)..]; context.Request.Path = context.Request.Method == "POST" ? "/New/Edit" : "/View/Index"; }