Where to put my changes to Program/Startup.cs
s
I'm doing a 12->13 upgrade, and I want to move all my custom stuff out of the new Program.cs file, to keep it untouched as I think it will make upgrades easier going forward. But I have some stuff, I'm unsure where to place. Can you help me with the following? - In Startup.cs/Configure, I have a
context.Database.Migrate();
context being the EF context for some custom db work, is injected into Startup.cs. - app.UseExceptionHandler("/error-500") in Startup.cs/Configure - app.UseResponseComporession() in Startup.cs/Configure - Host.....ConfigureAppConfiguration((context, builder) => { builder.AddJsonFile($"appsettings.Local.json", true, true).AddEnvironmentVariables(); }) in Program.cs/CreateHostBuilder Can I put everything in a Composer? I guess some of it should be middleware, at least the docs told me to do that for my CORS policy 🙂
d
Heyo! If you really really want, you can register your middlewares in a pipeline filter. I know many plugins register their middlewares that way. Everything else can usually be done with composers and components. I'm on mobile atm, so I can't share code snippets, but I can tell you that the URL Tracker for example uses a pipeline filter to register middlewares. That could be an example
s
Yeah, I figured that might be the way, but then which one of prePipeline, postPipeline, preRouting, postRouting should I pick? 🙂
d
It depends
s
120 Views